Drop bullet speed depending on distance

Get help using Construct 2

Post » Wed Jan 30, 2013 8:19 am

Hey-ho,

I'm having some headaches: I want a bullet to slow down proportionately depending on its distance from another object, so that by the time it gets to the object it stops.

The speed should only start to decrease when the distance between the bullet and target object is less than half of what it was originally.

Any ideas? I haven't been able to get any stable results.
B
27
S
8
G
5
Posts: 429
Reputation: 6,902

Post » Wed Jan 30, 2013 8:28 am

Something I did for someone else a while back that is almost what you want. Not quite, but the distance formula is in there. Pick it apart and see if it helps any..

light distance
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Thu Jan 31, 2013 1:10 pm

@procrastinator - Thanks for that, but I just can't seem to get it to translate to what I'm after. I may just have to live with what I've got, I have spent hours on it and it's really not so important at all.
B
27
S
8
G
5
Posts: 429
Reputation: 6,902

Post » Thu Jan 31, 2013 1:49 pm

Couldn't you compare positions, averaging the result as a variable then set the speed to this value ?
B
3
Posts: 6
Reputation: 287

Post » Thu Jan 31, 2013 1:56 pm

[QUOTE=LoPhOpHoRa] Couldn't you compare positions, averaging the result as a variable then set the speed to this value ?[/QUOTE]

Exactly, something like: Bullet.Speed = floor(distance(bullet.x, bullet.y, target.x, target.y)-stopDistance could work. Also add an event that rounds it to 0 if it goes negative. :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192


Return to How do I....?

Who is online

Users browsing this forum: mercuryus, mystazsea and 19 guests