How do I create rocket homing behavior?

Just started using Construct 2? Post your questions here

Post » Fri Apr 10, 2015 5:42 pm

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
B
31
S
8
G
3
Posts: 162
Reputation: 3,216

Post » Fri Apr 10, 2015 6:58 pm

every x second, set bullet angle towards target.
Frosty Elk AB
www.frostyelk.se
Have no fear, We come in peace!
B
13
S
3
G
1
Posts: 106
Reputation: 1,169

Post » Fri Apr 10, 2015 7:20 pm

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
B
31
S
8
G
3
Posts: 162
Reputation: 3,216

Post » Tue Apr 14, 2015 7:49 am

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.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,782

Post » Tue Apr 14, 2015 8:29 am

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)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Apr 14, 2015 12:41 pm

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
B
31
S
8
G
3
Posts: 162
Reputation: 3,216

Post » Tue Apr 14, 2015 1:04 pm

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Apr 14, 2015 4:25 pm

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
B
31
S
8
G
3
Posts: 162
Reputation: 3,216

Post » Sat Jul 04, 2015 6:29 pm

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! :D

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.
Image

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

CapX
Homing Rocket
B
16
S
8
G
1
Posts: 153
Reputation: 2,548


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests