How do I create a fountain-like trajectory of a bullet

0 favourites
  • 8 posts
From the Asset Store
******* Animated fountain environment prop *******
  • Hi Guys, I am trying to create a gun turret that shoots like that

    Gravity and Set angle behaviors do not help much in that case. What do you think?

  • For the first one you can do it with the bullet behavior and a negative gravity I think.

    The second one you'd have to use the custom movement behavior with a negative horizontal acceleration.

    Or you can do it with just events with and object "bullet" with instance variables vx and vy

    on space pressed

    --- player spawn bullet

    --- bullet: set vx to 100

    --- bullet: set vy to random(-20,20)

    every tick

    --- bullet: add -100*dt to vx

    --- bullet: set position to (self.x+self.vx*dt, self.y+self.vy*dt)

    ^-that's to do the second picture. Fiddle with it and you can make the bullets accelerate in the other directions.

  • For the first one you can do it with the bullet behavior and a negative gravity I think.

    The second one you'd have to use the custom movement behavior with a negative horizontal acceleration.

    Or you can do it with just events with and object "bullet" with instance variables vx and vy

    on space pressed

    --- player spawn bullet

    --- bullet: set vx to 100

    --- bullet: set vy to random(-20,20)

    every tick

    --- bullet: add -100*dt to vx

    --- bullet: set position to (self.x+self.vx*dt, self.y+self.vy*dt)

    ^-that's to do the second picture. Fiddle with it and you can make the bullets accelerate in the other directions.

    R0J0hound, thank you. Your method with instance variables worked.

    Some nuances:

    I could not set vy to random(-20,20). It sets me 0 instead.

    Also, should we rotate the bullet separately to achieve the second way of trajectory?

  • I guess you could have a particle play at the gun barrel, and then spawn the bullets at specific points facing the way you want.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 1

    You can use random if you set it with events.

    2

    You can set the angle to the angle of motion by adding the action:

    Bullet: set angle to angle(0,0,self.vx,self.vy)

  • R0J0hound,

    Could you precise what you mean under setting angle of motion to (0,0,self.vx,self.vy)?

    I can set angle of motion only in 0 or in self.vx (self.vy).

  • heliogame

    "angle()" is an expression so I mean using the expression

    angle(0,0,self.vx,self.vy) [/code:3yxzni2q] when setting the angle.  Also I didn't mean using the bullet behavior.  "bullet" was just the object name I used.
  • heliogame

    "angle()" is an expression so I mean using the expression

    angle(0,0,self.vx,self.vy) [/code:3pkt25v9] when setting the angle.  Also I didn't mean using the bullet behavior.  "bullet" was just the object name I used.
    

    Got it. Thank you.

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