# Little stealth game

Continuing the discussion from Introduce yourself:

I’m loving the little stealth game. Where are you going with it?

I’m trying to make a little stealth game where you control a little cube that has go from point a to point b without being seen by the enemy cubes. I’m still trying to figure out how to get the AI to follow a path. I’m using rigidbodies and forces for movement but it seems to be quite complicated to get movement to work well like this. The problem is that i can’t seem to figure out how to get the whole collision system to work without rigidbodies.

Basically, my problem is:

• without rigidbodies, no collisions (i may have to right them myself) but i can just play with positions and velocities to get from point a to point b (super simple)
• with rigidbodies, awesome collisions, but using applyForce and applyImpulse to move around is really hard

I just started playing around with that API so I’m very new to it, so I wonder if there was a way around this problem (maybe I haven’t looked hard enough)

I see,

You’re best bet is probably to stick with the rigidbody system as it will save you having to write a lot of collision code, also you’ll get raycasting built in which will be useful for your line of sight code.

You can set the velocity of a rigidbody directly

``````this.entity.rigidbody.linearVelocity = pc.math.vec3.create(10,10,10);
``````

This should work OK, though you have to be a little careful of setting the velocity if you want falling to work correctly.

Alternatively, take a look at the code for the platform starter kit: http://playcanvas.com/playcanvas/starter-kit-platform/editor/platform_character_controller.js

Which uses applyImpulse(), plus friction and some artificial drag to provide some snappier movement.

1 Like

Awesome! Thanks a lot, it works quite well.

Now that the AI behaves like I want it to I can work on making levels for this game.

Thanks again!

1 Like

From what is there in level 1 at the moment, I already really like the look of this game

1 Like

I’ve only just played this for the first time. Well done, Hassan! Looking foward to v2.0.

1 Like