Game Development Community

How Do I stop a scene object?

by Brandon · in Torque X 2D · 02/08/2009 (12:28 pm) · 2 replies

If I have a scene object that just has the AIChase component how can I stop it after it gets started chasing?

In other words I want it to just stand still the entire time, but if the enemy comes into range chase after it, but then if the enemy goes out of range stop right where you are, don't go back to the starting point.

Currently if I run this and my player gets out of range the scene object stops chasing, but the velocity keeps it moving.

I've tried _sceneObject.Physics.Velocity = new Vector2(0,0); But that does not stop it.

#1
02/08/2009 (12:38 pm)
HMM Nevermind. Seems that SceneObject.Physics.Velocity = new Vector2(0,0) does stop it, but you can't just call it once. You have to put that in an update. Not sure I understand why that is. I guess something to do with momentum. Not a big deal I guess, I'll just have each state manage the velocity and if it's supposed to be sitting still then velocity = 0,0
#2
02/08/2009 (5:26 pm)
If you're using the PSK anything that is an Actor has a _horizontalStop method that stops Actors dead in their tracks.