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

Get help using Construct 2

Post » Sat Jun 20, 2015 6:48 pm

Hi Guys, I am trying to create a gun turret that shoots like that

Image

Image


Gravity and Set angle behaviors do not help much in that case. What do you think?
B
8
S
2
Posts: 48
Reputation: 646

Post » Sat Jun 20, 2015 7:06 pm

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.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Sun Jun 21, 2015 11:11 am

R0J0hound wrote: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.
Image

Also, should we rotate the bullet separately to achieve the second way of trajectory?
Image
B
8
S
2
Posts: 48
Reputation: 646

Post » Sun Jun 21, 2015 3:23 pm

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.
B
7
S
1
Posts: 20
Reputation: 585

Post » Sun Jun 21, 2015 3:28 pm

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)
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Sat Jun 27, 2015 8:57 am

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

Image
Image
B
8
S
2
Posts: 48
Reputation: 646

Post » Sat Jun 27, 2015 8:21 pm

@heliogame
"angle()" is an expression so I mean using the expression
Code: Select all
angle(0,0,self.vx,self.vy)
when setting the angle. Also I didn't mean using the bullet behavior. "bullet" was just the object name I used.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Sat Jun 27, 2015 9:59 pm

R0J0hound wrote:@heliogame
"angle()" is an expression so I mean using the expression
Code: Select all
angle(0,0,self.vx,self.vy)
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.
B
8
S
2
Posts: 48
Reputation: 646


Return to How do I....?

Who is online

Users browsing this forum: Rhindon and 16 guests