I Need Some Help With My Player Collision Script

This is what I’ve been doing the last couple days :

It’s not pathfinding, it’s just obstacles avoidance.
It uses CollisionSegment for collision checking within his view range. The white spheres are the movement traces, and the rgbCubes are the target points, where the avatar must look at, to maintain smooth movement .
Now the avatar doesn’t have to hit into everything. :smiley:

Jo that’s fantastic! Something like that is just what this script needed :smiley:. You guys are absolutely terrific, there is no way that I could have done this on my own.

Jo, if you don’t mind, could you post your code for it? I probably won’t understand it :unamused: but I’d love to see how you do this, also the more code I study the more I’m learning :smiley:.

Thankyou both so much.

Sure I’ll show it. ATM I’m still optimizing it, trying something better to improve it here and there. I haven’t satisfied YET ! :slight_smile:

I thought it’s quite acceptable, so here it is.
I changed something to give me enough space to play with my approach :

  • I disabled the Pusher
  • I disabled the camera-segment collision
  • I extended the zoom out threshold, so that I can see the entire terrain
  • I removed the rock collision bitmask 0, because the collision handler Floor makes the avatar jump up onto the rock from the ground.
  • I colored the tress black to easily distinguish them when viewing from the sky

My obstacles avoidance method is “avoidObstacles”, called within avatar update method. It’s setup is in “initActor”. It hasn’t been well tested for larger avatar radius. You can display the traces by changing the global constant “TRACE”.
Get it –[HERE]–

I started looking at your code, ynjh_jo. Ralph can avoid the new cylinders, but gets stuck inside the rocks! I’ll play with it some more.

Sorry it took me so long to reply. I had to study for finals.

ynjh_jo: Still thinking in C, I see.

What’s wrong with this picture?

I didn’t think it was supposed to do that, so I took a look at your new code. It still looked like convoluted functional-style so I excised a tracer class and untangled an __initAvoidance method. I think I understand a little of what you are trying to do. You appear to have used a collision segment like insect feelers to check for obstacles.

But there appears to be some serious flaws in your algorithm.

First, you’re scanning a single collision segment across the avatarFOV, so you have to run a collision traverser multiple times each frame! This is horribly expensive. And all this for only six angles!? It would be much better to use six collision segments at once, and only run the traverser once per frame. You could even use many more than six without causing the horrible slowdown your current algorithm does.

Second, Ralph doesn’t even reliably avoid obstacles! As you can see from the picture Ralph got stuck inside a cylinder and just runs around in circles.

How is that demo coming btw?

I couldn’t see your picture.
About the several collision passes per frame, yes I know it’s expensive, and I haven’t got anytime to try creating several segments and traverse them all once per frame.
You see, that algorithm only takes the closest collision point into account, so if the surrounding is clear, the avatar would head up to the destination point. I limit the segments length to avoid the unnecesssary collision detection against more objects. In that algorithm, the longer the segments, the worse the result.
In fact, right after developing that algorithm, I tried to develop a better algorithm, by putting the farthest collision points into account. So if there is no collision in the given angle, then the collision point is set at the avatar’s farthest range of view (in that angle of course), after checking if that angle is the closest angle to the destination point.
The whole idea is : if there is close obstacle, avoid it, if not, go to the farthest collision point, the closest angle to the destination point.
At that moment, I haven’t done it correctly, and I haven’t got anytime to touch that algorithm again. I’ve been in the middle of interns since November, and now I only have less than a month to finish it. tooo bad.

Oh, one more thing, is there a way to perform collision detection against frontfaces only ?

Looking around the forum this issue is the one that deals with the problem I have though in my tests does not work.

To summarize them say that I have a game client / server I tested in the same PC and use Parallel to move to the player with the mouse only.

Try to eliminate the interval (Parallel) with the code I found here and put below but after a few consecutive clicking an error is generated in the interval:

    if self.playerMovement:
           self.playerMovement = None

After studying the classes and their methods to modify the code as follows:

    def mover(self,destino):

            # Rota y mueve al jugador
            self.destino = destino
            self.nodedestino = NodePath('destino')

            if self.moverjugador != None:
                if self.moverjugador.isPlaying():
                    manejador = self.moverjugador.getManager()
                    self.moverjugador = None

            duracion = self.actorNode.getDistance(self.nodedestino)/self.velocidad
            self.desplazamiento = self.actorNode.posInterval(duracion, self.destino)
            self.ajustaraltura = LerpFunc(self.altura, duration = duracion)
            self.animacion = ActorInterval(self.actor, 'correr', loop = 1, duration = duracion)
            self.moverjugador = Parallel(self.desplazamiento, self.ajustaraltura, self.animacion)

Sorry that the code is in Spanish but I am speaking hizpana and forgive my English.

With one client open takes time to make the error but with 3 or 4 gives fast:

Someone can help halt and eliminate Parallel intervals without generating an error? I have 2 weeks in this and I see no light.