Is 'move to' dynamic? I am having problems

charlieaf92charlieaf92 Member Posts: 84
edited November -1 in Working with GS (Mac)
To eliminate new actor spawning during gameplay, I have developed an actor 'recycling' system that makes them invisible and moves them off the screen when they are killed. Then, they re-activate and start over.

The problem that I am having is that once I move them off the screen they continue to move in the same direction that they did when they originally spawnd - regardless of what direction they should be moving.

I have 'Move To' setup to global X and Y attributes that are constrained to their target's X and Y.

When the enemy is killed, I change the enemy's X and Y attributes to move them off screen.

Shouldn't 'move to' by dynamic based on the actors relationship to the coordinates? I have tried setting the relative to scene and actor with the same results for each.

Any advice is appreciated.

Thanks!
Charlie

Comments

  • RHRH Member Posts: 1,079
    I think you're overcomplicating what you are trying to do in all honesty. I'd just have a boolean on the actor, such that:

    `when alive is true
    move to target x and target y
    otherwise
    change attribute self.pos.x to ??
    change attribute self.pos.y to ??`

    As for your method, do you have 'run to completion enabled'? It could be that but I'm not sure.

    Sorry if this was more of a nuisance than an answer, hope it helped though!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I just did a little test with move to. It seems that move to will cause the actor constantly check the game.playerX and game.playerY attributes that I have constrained to the moving target's X and Y so that as the target moves the chasing actor curves nicely to chase it. BUT, when the chaser successfully reaches the target it stops moving even though the target has moved on and is no longer under the chaser. There seems to be a switch that turns off the behavior when the target coordinates have been reached.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I just did a second test. I put move to in an actor with no rule wrapped around it. Then I put a separate rule that says

    when self.positionX is < 100
    change attribute self.positionX to 400
    change attribute self.posiitonY yo 160

    When I tested this it changed to 400,160 and immediately continued chasing the target.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Accelerate to does not seem to stop even when the target has been reached.
  • charlieaf92charlieaf92 Member Posts: 84
    Interesting. Thanks for the replies RH and SC.

    RH - you might be right about over complicating it. I have a group created for when the enemy dies that includes all of the necessary death pieces (increase score, death effect, etc) - and it also has the 'reset' pieces. Right now the moveto is outside of all rules, but I have also tried moving it into the reset piece as well.

    SC - when you teleported your actor back to a new position - was it different than its original start position in relation to your target? To me it sounds like your test shows it is dynamic and should be working. Maybe I just need to retry it a few more times - it was kind of late, maybe I overlooked something obvious.

    By the way - this particular target is stationary, I am not sure if this makes any difference as I am still using constrain attribute to track it globally.

    Thanks again
    charlie
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I moved it to a new position (not the same that it started from).

    If you use accelerate to it may work better, but you may want to control the speed. The easiest way to do this is in the actor attributes panel under motion. Just set the max speed to what you had in the move to speed box. Then set you accelerate to speed really high (2000).

    Give that a try - I think you may like the results.
  • charlieaf92charlieaf92 Member Posts: 84
    I did some more testing and I don't like accelerate. I want to use move to.

    I tried hard coding the coordinates that the enemies seek and it still did not work correctly. Then, I tried setting them to seek the player's global X and Y coordinates and it works perfect. I think the reason is that they are changing.

    My guess is (and someone please help me out if you know better) that GS is taking the the X and Y of the actor and the target and calculating the slope. Then, making adjustments to X and Y to draw a line between the two.

    BUT it is not updating its equation unless the X and Y of the target changes.

    This is definitely a situation where some source code could help. Programming without code is great, but sometimes you need to understand the logic behind what is going on under the hood.

    Any thoughts?

    Thanks
    Charlie
  • charlieaf92charlieaf92 Member Posts: 84
    FYI - I tested my theory and it worked.

    It should definitely be noted in the documentation that the MOVE TO behavior only updates when the target X and Y coordinates change. Changing the coordinates of the actor WILL NOT updates its path.

    charlie
Sign In or Register to comment.