Constrain Attribute is not updating, thoughts?

CluvCluv Member Posts: 229
edited May 2012 in Working with GS (Mac)
Hey!

I am working on a function in my game where an actor move towards another actor on screen, then stops. I am using "Magnitude" to check distance between the two actors (one actor is static, the other is moving towards the first). When the actors are on top of each other exactly, I would like for the moving actor to stop iterating and updating its variables, hopefully saving memory in the long run. I can't use the "collide" function because that I am using a pathfinding formula where the moving actor may go through other actors of the same type as the static actor.

The issue is that I would like to constrain a secondary variable to hold the "Magnitude" formula. I would like to use this variable to stop the check of distance when the distances are equal (or close to it). Currently, I have to create a variable for my constraint because Gamesalad can't take just a formula as a condition for a rule. However, constrain attribute won't iterate. I can use the magnitude function on its own, and the actor pathfinds fine, but right now, it will continue to iterate its other variables until I give it a stop condition.

Any thoughts?

Thanks!
C

Best Answer

  • tatiangtatiang Posts: 11,949
    Accepted Answer
    The only thing (hopefully) that I don't understand about what you wrote is "However constrain attribute won't iterate." Besides that, it sounds like you just need to have a rule When game.ZERO (integer set to 0) < Magnitude(x1-x2,y1-y2) ... constrain attributes, etc. If zero is too small, make it game.DistanceWhenStopped (integer set to some other small value).

Answers

  • CluvCluv Member Posts: 229
    @Tatiang, I made a simple calculation error that I caught just now. And you are right, I just need a variable that holds the final value. I will test it and see how it goes. Thanks!
Sign In or Register to comment.