Actor not moving after a move to instruction

wln7844wln7844 Member Posts: 6
edited March 2013 in Working with GS (Mac)
I'm trying to create random AI movements in a maze type environment.
My problem now is I have a "Move To" instruction when the Actor overlaps with a panel placed in the maze. The Actor then moves to an X,Y position I set. When it gets here I want it to move again when the Attributes "Self Postion" X,Y are equal to where I sent it to In the previous "Move To" instruction. But now my Actor moves to the position then stops and doesn't do the next instruction. Any ideas what I'm doing wrong here would be greatly appreciated.

Comments

  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    In my experience with Move To and Interpolate, the actor never reaches the exact point you want it to. It'll be .0123 pixels off, and thats enough to throw off the rule.

    I would suggest instead of having it once it reaches the point, have it try to reach the point plus or minus one pixel.

    However, someone else might have a better solution than me.
  • wln7844wln7844 Member Posts: 6
    If that's the case then for my next move is there a Formula that would allow my next move to go from an X,Y point that is say in an area roughly around where I have sent the Actor to? Like say if I was moving the actor to X=40 and Y=40 and could I then move it from an area around those values?
    Thanks for the input. It is much appreciated
  • contrasthallcontrasthall Member Posts: 131
    try a different approach and see what happens either try a greater then position statement a few pixels before that exact spot or even just one pixel before that spot or see if it responds to a actor there /overlap then work from there and figure out the problem...if any of this works ill try to continue helping
  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    edited March 2013
    Yeah, I assume at this point in your rule you have, let's say when X = 40. If you change it to if X>=39 and X <=41, it might be able to pick up the next step of the rule.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2013
    @wln7844 Welcome to the forums. Please don't open multiple discussion threads for the same (or similar) issues. Also, make sure that your discussion titles are specific and related to the question or issue you need help with.

    I've merged your two threads.

    Also, if you can post a sketch (see my signature for instructions) of what you're trying to achieve, I'm sure someone here can come up with a solution. Are you trying to snap to a grid or something else?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • wln7844wln7844 Member Posts: 6
    Thanks for the feedback. It's a maze like a Pac man type game. I have precise X and Y co-ordinates for each corner and intersection. Just trying to get my Ai to follow them is the problem. I've tried using the invisible actors at each intersection to generate a random movement depending on where it is. Tho if its not precise enough my Ai just sticks to the wall and misses the point where it is supposed to be. It's proving to be a lot more difficult than I previously thought.
    Using the X > 39 and X < 41 worked after I put in a timer to keep checking my X Y position every 0.001 seconds. Will repeating this over for each intersection cause my game to run very slow?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I recommend that you change the actor's position to the exact grid mark and then allow the actor to move again once that has been established.

    This is usually done as follows:

    Change Attribute self.position.X to (floor(self.position.X/game.gridSize))*game.gridSize

    You may need to use ceil in place of floor or to actually use a mod function (more on that later if you need it...) to determine whether to use ceil or floor in that formula.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • contrasthallcontrasthall Member Posts: 131
    i wouldnt do a timer to check just do the create rule, if greater then 39 and then aplace a move to rule inside that, no need for a crazy timer to bog down ur game almost every pixel it moves it will recheck these rules which would be the same as a timer .01, basically if ur running at 60 frames a second ur game is checking EVERY rule before it post a new frame a second thats how programming works which is why some new games on ps3 n xbox get bogged down to 30 frames a second because they have so much to check, hope this helps try to stay away from timers when necessary other wise u could miss a oppurtunity to move ur character because its not time get even though u r greater then the x > position u set, then maybe ur character bounces off a wall and by the time ur timer checks you are now actually less then....thus the timer screwed u over.
  • wln7844wln7844 Member Posts: 6
    Thank you all for your input. I ditched the Timer and have my Ai moving through my maze. Now I'm having an issue with how my Ai collide with each other in the maze. Is there a formula that results in the complete opposite of a number.
    I would like to invert my X,Y velocity of my Ai if it overlaps or touches another Ai.
    What formula would best suit this. Say my Ai was travelling at X=100 Y=0 and touched another Ai I'd like that value to change to X=-100 Y=0
  • wln7844wln7844 Member Posts: 6
    Is it just
    Change Attribute
    self.motion.linear.X = -(self.motion.linear.X)
    And the same for the Y velocity?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yes, you can do that. Change Attribute self.motion.Linear Velocity.X to (-1)*self.motion.Linear Velocity.X

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.