smart bullet?

0 favourites
  • 7 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • 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? <img src="smileys/smiley1.gif" border="0" align="middle" />

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


  • you can also lerp the value of the randomness


    missile: set dumbFactor to lerp(0,10,self.speed/maxSpeed)
    missile: set angle to (player.X+random(-dumbFactor,dumbFactor),player.Y+random(-dumbFactor,dumbFactor))
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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:


         - Bullet.setAngleOfMotion(Player.x, Player.y)

    If(distance(bullet.x, bullet.y, player.x, player.y >= (some value calculated by the distance)

         - Make dumb?

  • 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

    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))

    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.

  • 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?

  • 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 <img src="smileys/smiley20.gif" border="0" align="middle" />

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