How to make an actor STOP moving when in contact with another actor?
QwazzMe
Member, PRO Posts: 39
Hey
Here I am again with another stupid question...
In my game, a shepherd moves a sheep around and when it collides with a "grass" actor it is supposed to stop moving for some seconds and then proceed.
I've tried creating a bollean attribute, when true (colliding with grass) Change attribute to self.physics.movable to: 0
And with a timer, after 5 seconds the Change attribute self.physics.movable should change again to 1 (movable, right?)
It's not working... the sheep is still moving when touching the grass actor...
Help, anyone?
Comments
You may want to try using Motion.Linear.X (or Y) set to a value, and then change that value to 0 when it comes in contact with the grass actor instead of turning on and off the moveable physics attribute. You would script it the same way you have here, but use Linear Motion instead of Physics.
Hi @Qwazzme Your on the right track... the only thing is, there a couple of attributes in GSC that can't be changed during runtime, and Moveable is one of them.
So try this in the sheep actor, see if it helps:
Collide with actor of type shepherd ---which presumably you already have
Rule: When actor overlaps or collides with actor grass
Timer: For 5 seconds
Collide bounce when colliding with actor grass
That seems to work - I did a test - though there's another problem that occurs when your shepherd actor will overlap the sheep actor, so you'll have to add a collide behaviour (with sheep) in the shepherd actor too.
Hope that sorts it for you.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Thank you guys!
@gyroscope, I've tried this, but the sheep does not stop, it goes right over the grass....
Hi @Qwazzme Take a look at the test file I did, see if your file has any difference...
for some reason, GS forum won't let me attach the file so here's a Dropbox link:
https://dl.dropboxusercontent.com/u/14060718/DG collide testv1.gameproj.zip
P.S For the record, the sheep actor is being pushed by the shepherd actor so I'm almost certain that setting the sheep actor's linear velocity to 0 would have no effect....
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Not a stupid question at all. Should be simple but it's very frustrating to do sometimes. Linear velocity X and Y to 0 with a timer should work. But i have to do trial and error for each situation!
Age of Dominion RTS for iOS
Age of Dominion RTS for Android
Thank you guys.
Gyroscop
I did this, but the sheep goes right over the grass, it doesn't stop...