Homing missile Forum Home > Construct 2 General > How do I....? |
Post Reply
|
| Author | |
Post Options
Quote Reply
Topic: Homing missilePosted: 17 Mar 2012 at 7:37pm |
|
|
Hello
I am in the process of porting my game from Game Maker to C2 and all has been smooth so far except for this issue I need the player to shoot an object which will lock on to the nearest enemy of a specific type and then move towards it until they collide So basically i need to 1. Find the nearest enemy 2. Make sure the missile follows it 3. Make the missile continue in a straight line if that enemy is destroyed before it hits its target Apologies if this is already covered somewhere but i looked through the FAQ and did a search in this section but didn't find anything i could use Any help will be much appreciated |
|
![]() |
|
Post Options
Quote Reply
Posted: 17 Mar 2012 at 8:29pm |
|
|
If you are using the bullet behavior, or move at angle.
1: Bullet pick closest target 2: Bullet set angle towards target 3: Wont matter if 1 and 2 are continuous. |
|
![]() |
|
Post Options
Quote Reply
Posted: 17 Mar 2012 at 8:37pm |
|
Thank you for your reply I don't understand I am using bullet behaviour but i don't see anything about pick closest target in it's behaviour I am hopeless at trigonometry so i was hoping i could do this some other way. Like in Game Maker there is a move towards behaviour you put in the every tick event What am i missing? Edited by jn2002dk - 17 Mar 2012 at 8:39pm |
|
![]() |
|
Post Options
Quote Reply
Posted: 17 Mar 2012 at 9:54pm |
|
![]() |
|
Post Options
Quote Reply
Posted: 17 Mar 2012 at 10:01pm |
|
You are awesome! That's exactly what i need Thank you, thank you, thank you
|
|
![]() |
|
Post Options
Quote Reply
Posted: 19 Mar 2012 at 5:39pm |
|
|
Thanks Yann, great work! you're excellent.
|
|
![]() |
|
Post Options
Quote Reply
Posted: 19 Mar 2012 at 11:08pm |
|
|
If you want the missiles to behave a bit more realistically, I would suggest, instead of setting the angle straight towards the object, every tick set the angle to: anglelerp(rocket.angle,angle(rocket.x,rocket.y,target.x,target.y),dt*somespeedfactor)
|
|
![]() |
|
Post Options
Quote Reply
Posted: 21 Mar 2012 at 10:13am |
|
Will try this I can't claim to have a firm grasp of what lerp does exactly but it can't hurt to try. Thank you:) |
|
![]() |
|
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |