How to make an object move to another object's image point?

Just started using Construct 2? Post your questions here

Post » Mon Jan 12, 2015 9:11 pm

I'm trying to make a complex enemy that involves throwing their sword, then moving to that sword's position.

My attempted method at doing this was have the enemy sprite spawn a sword sprite on them, and then have the sword sprite move to a separate image point on the enemy sprite. Doing it this way would just fix all the issues I'm having for the desired effect, and make the event tuning much less complicated. Can it be done?
All I was able to do was make the sword sprite teleport instantly to the enemy sprite's image point, or have it rotate and set it's angle to the point.
B
20
S
5
Posts: 108
Reputation: 1,473

Post » Mon Jan 12, 2015 10:00 pm

Look up imagepoints. You can add them to sprites and refer to their X and Y positions. I would suggest to follow a beginners tutorial like the Ghost Shooter if you haven't already :)
B
84
S
20
G
6
Posts: 175
Reputation: 8,156

Post » Tue Jan 13, 2015 12:40 am

Edit: can't post links, yolo.

sprite1.ImagePointX("pointA") is what you'd want to get from that. You'll have to set an acceleration or speed on the sword to actually get it to move from there, and figure out a way to make it stop after a certain distance or on collisions.

Where pointA is the name of the imagepoint. By default this is named to an integer, but you can be more descriptive. You may have to change a few things with how the sword is bound to the enemy to get this to function properly. In other words, you can't use system>every tick anymore (I think). I'm new at this, but the simplest solution is to have a boolean toggle whether the sword is in the thrown state, and keep it bound to the enemy if it is not, and have it do the throw functions when it is.
B
3
Posts: 2
Reputation: 179

Post » Wed Jan 14, 2015 7:54 pm

That's exactly what I needed to know, thanks!
B
20
S
5
Posts: 108
Reputation: 1,473


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests