smart bullet?

Get help using Construct 2

Post » Sat Jan 14, 2012 10:53 am

I have a project where something shoots a heat seeking missile, So every tick its angle is set to the players position using the lerp() function so its a little slower to target the player.

But when the bullet is spawned i want it to:
- Start at a speed of 10 and increment to 100 <- This is easy using lerp.
- the higher the speed is then i want the bullet to be dumber..
     - Its currently using set angle to position on the bullet behavior, its setting it to the players position.

Any help?
B
2
G
1
Posts: 6
Reputation: 474

Post » Sat Jan 14, 2012 11:24 am

Mh .. you can have a loop like every secound set angle to player + int(random(5)) .. so the bullet will gain stupidity ^-^

Cheers
B
17
S
4
G
4
Posts: 94
Reputation: 3,058

Post » Sat Jan 14, 2012 9:46 pm

you can also lerp the value of the randomness

like
[code]missile: set dumbFactor to lerp(0,10,self.speed/maxSpeed)
missile: set angle to (player.X+random(-dumbFactor,dumbFactor),player.Y+random(-dumbFactor,dumbFactor))[/code]Yann2012-01-14 21:47:52
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Jan 14, 2012 10:09 pm

@Yann, Thanks..

But i don't really understand. Can you knock up a little example?

I think i might need to use distance.

I kinda want it to gain stupidity as the distance from the bullet to the player is small.

Something like:

System.EveryTick:
     - Bullet.setAngleOfMotion(Player.x, Player.y)
If(distance(bullet.x, bullet.y, player.x, player.y >= (some value calculated by the distance)
     - Make dumb?

B
2
G
1
Posts: 6
Reputation: 474

Post » Sat Jan 14, 2012 10:44 pm

Well, you did say "the higher the speed is then i want the bullet to be dumber"
So it was just a translation of that
Now you want it to be dumber when close, it might be weird but it's the same exact idea

[code]missile: set dumbFactor to lerp(10,0,clamp(distance(missile.x,missle.y,player.x,player.y)/maxDistance,0,1))
missile: set angle to (player.X+random(-dumbFactor,dumbFactor),player.Y+random(-dumbFactor,dumbFactor))[/code]
Here you will have:
if distance = 0 -> dumbfactor = 10
if distance > or = to maxDistance -> dumbFactor = 0
And all the in-between

so if dumbFactor = 10 the missile will aim in a 10x10 area around the player.Yann2012-01-14 22:46:06
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jan 15, 2012 3:31 pm

thanks @Yann, Your right it looked silly.

I just need it to constantly follow the angle of the player, then if its rather close to the player carry on the angle it was, So stop following the player... Is that possible?
B
2
G
1
Posts: 6
Reputation: 474

Post » Sun Jan 15, 2012 3:58 pm

Gee Yann, you allways amace me with your math skills.... I just order a book and hope to get a chance to step a little up to your knowledge
B
42
S
19
G
12
Posts: 723
Reputation: 13,911


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests