"Move to" the location of a another actor without stopping

Hello all !

I use "move to" to move an actor A toward the location of the actor B (which is moving)

Once done the Actor A stop, but I want this actor to continue the movement to go out the screen.

How can I do ?

Comments

  • bob loblawbob loblaw Member, PRO Posts: 793

    one way, instead of move to, use change attribute to set the speed of linear velocity x and y.

  • goubet.patrickgoubet.patrick Member, PRO Posts: 9

    Thanks Bob !

    I don't understand how by changing the speed the actor A will meet the actor B ?

  • bob loblawbob loblaw Member, PRO Posts: 793

    sorry. I mis-read your question. scrap that suggestion.

    so as an example, to see if I am now understanding, you want something like a shot fired at a point in the direction of another? to do that, you can figure out the angle between actor a and actor b, then use the 'move' behaviour, with the direction set to that angle between the two actors.

    so in the move behaviour you could set:

    • direction to: atan(actorA.positionY - actorB.positionY)/(actorA.positionX-actorB.positionX)
    • relative to: actor
    • move type: additive (I've never actually tried 'stacked' so don't know what that is)
    • speed: what ever speed you want it to move

    in the example of an enemy firing at the player. you would have two global variables that are constrained to the player's x and y position. the above move behaviour would be inside a 'shot' actor, and that shot actor would be spawned from your enemy when the player reaches a certain distance from the enemy (can use the magnitude function to work that out)

  • goubet.patrickgoubet.patrick Member, PRO Posts: 9

    Thanks a lot ! I will try this

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    I think the Accelerate Toward Behavior is persistent, un-like the Move To. You might try that as well.

Sign In or Register to comment.