How do I - move a sprite toward another [SOLVED]

  • Hi

    I have searched the forums and found many replies to this question, one of which is this thread:

    So the "enemy" sprite in my case, moves towards a target sprite and I am sure I got this working by adding a bullet behaviour and then using the set angle of motion and then setting this to `angle(Self.X,Self.Y,TestTarget.X,TestTarget.Y) but although this moves towards the target sprite it does not stop when reaching the sprite , instead it continues on. What is even more frustrating is that I had this working where it did stop and foolishly did not save that project on the basis that I would remember what I had done the day after - fool me!

    Please can someone advise on this and I am using the free version at the moment and I tried the plugin that was mentioned on the above thread but this does not work as Construct errors on load up and I can only presume this is because I am using the free version.

    Thanks

    TimCS

  • If you use a bullet, then there are two ways to stop a bullet. Or set its speed to zero, or set the behavior to dissabled.

    Question is now, when to stop it.

    Easyest is, on colission with destination object .. stop the bullet.

    Ther are ofcours other ways to do this.

    Use a plugin like:

    behavior-moveto_t63156

    Use lerp.

    https://www.scirra.com/tutorials/378/cr ... -with-lerp

    Use pathfinding.

    https://www.scirra.com/manual/154/pathfinding

    Use set angle towards an object & move forward

    And this list is still not complete.

  • 99Instances2Go

    Thank you for your reply, the first plugin you mention is the one I tried to use with the free version of Contruct 2 but on loading construct 2 , it errors and does not work . Should these plugins work with the free version ?

    With regards your suggestion to stop the bullet on collision with the object, some questions on this idea, do I add this as another event and if so is this a every tick ? and I would like the enemy sprite to stop mainly in the centre of the target or perhaps have control over the position of the enemy target when it overlaps the target sprite.

    Thanks

    TimCS

  • I suggest you go back to that plugin, first.

    It is a behavior.

    So you gots to install it in Program Files\Construct 2\exporters\html5\behaviors

    A behavior = https://www.scirra.com/manual/72/behaviors

    Regarding the bullet, on collison it stops at the collission boundarys of the distination object.

    To stop a it at exactly then center, the bullet is not the best solution.

    Regarding the other question, did you complete at least one tutorial ?

  • Thanks for pointing that out, it now works, The only issue now is that the enemy object is going behind the target object and they are on the same layer so its not that, I cannot see any kid of priority settings or infornt or behind option. Any thoughts or should I post this as another question ?

    ** EDIT **

    Scrap that last question on the enemy object going behind the target - figured it out - right click on the emeny object and change the Z order to send to top of layer

    Thanks again

    TimCS

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Always happy when someone figures it out themselfs.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)