How do I create rocket homing behavior?

0 favourites
  • 9 posts
From the Asset Store
Game "Neon Rocket" with complete Source-Code (Construct 3 / .c3p)
  • Hello;

    I want to shoot a rocket at a moving target, I want it to home onto the target.

    Is there a behavior for this similar to the bullet behavior? I don't see one.

    Thanks for your time

    Winkr7

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • every x second, set bullet angle towards target.

  • Thanks Frostyelk.

    But I was looking for something more involved--ie suppose my rocket has a max turning rate? Say, 5 degrees per second?

    Anyway, thanks for your input.

    yours

    Winkr7

  • look at "rotate towards " which allows you to set the angle (ie rotate towards target.x, target.y by 1 degree) by altering the degree you will alter the turning rate.

  • This would allow a deviation of 6 degrees per second, but is one way to do it:

    every 0.1 seconds - bullet set angle of motion = clamp(angle(bullet.x,bullet.y,target.x,target.y), bullet.Bullet.AngleOfMotion-1, bullet.Bullet.AngleOfMotion+1)

  • Thanks RamPackWobble and LittleStain;

    I can get the turning rate limit this way and thanks for the help, but there are other rocket behavior features--it runs out of fuel, accelerates initially. I was hoping we had a rocket behavior somewhere,

    I guess I can post this as a request.

    Once again, thanks for your time.

    yours

    Winkr7

  • The behaviour you'd like from the rocket would (almost certainly) be different from the behaviour somebody else would like for a rocket.

    Creating all these different possibilities would be near impossible.

    It would also feel like a waste of time, considering the effects can be achieved by adding events.

    The fuel could run out based on time - adding the timer behaviour would work for this

    The fuel could run out based on distance traveled - subtracting the distance traveled from the amount of fuel would work for this

    Initial acceleration could be achieved by increasing the speed from 0 to the max speed after the rocket is spawned.

  • Good point LittleStain.

    Even so, everyone likes the turret behavior, and your arguments about over-specialized behavior apply to it as well.

    You have outlined a good way to duplicate this behavior with events, and I thank you for it.

    yours

    Winkr7

  • Just saw this old post which ive replied on the request - so im putting it here too.

    Request thread

    https://www.scirra.com/forum/viewtopic.php?f=183&t=128861

    But also as an addition to the game im currently making, but im sure other people could use something similar to this. So comment if you like, or grap the CAPX to improve it.

    Features:

    Higher intial speed, that switches to a constant speed after a while.

    Fuel gauge for each rocket, explodes when used up.

    Rockets explodes on collision with solids

    Rockets explodes when at a certain distant of its target - NOTICE: there is a event to chage it into "Upon impact"

    When rockets cannot see their main target, they expand their vision and search for a secondary target. NOTICE: it wont do anything without a target.

    .....You can hide from the rocket - yay!

    Known bug(s)

    For some reason, sometimes the rocket explodes when they are being launches. Seems like there is a loop somewhere when one rocket is exploding, new ones will also do it.

    Fuel Gauge

    Spends X amount of fuel each second.

    Target Switching

    When the rocket cannot see you, it expands it vision field and finds a secondary target, nearest itself.

    CapX

    Homing Rocket

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