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

Just started using Construct 2? Post your questions here

Post » Tue May 31, 2016 3:48 pm

Message: timcs can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hi

I have searched the forums and found many replies to this question, one of which is this thread:
how-do-i-move-to-a-position_t163847?&hilit=move+sprite+toward+another+sprite&start=10

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
Last edited by timcs on Fri Sep 09, 2016 9:32 pm, edited 1 time in total.
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Post » Tue May 31, 2016 5:33 pm

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.
B
33
S
18
G
28
Posts: 2,457
Reputation: 20,878

Post » Tue May 31, 2016 6:26 pm

@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
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Post » Tue May 31, 2016 7:55 pm

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 ?
B
33
S
18
G
28
Posts: 2,457
Reputation: 20,878

Post » Tue May 31, 2016 8:42 pm

@99Instance2go

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
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Post » Tue May 31, 2016 10:46 pm

Always happy when someone figures it out themselfs.
B
33
S
18
G
28
Posts: 2,457
Reputation: 20,878


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest