How do I create a bullet movement with trajectory

Get help using Construct 2

Post » Thu Jan 14, 2016 6:53 pm

I am trying to create the same concept from the link below in Construct2
http://gamemechanicexplorer.com/#bullets-5

I have found some examples on the forum but none is complete.
Three I am trying to accomplish here:
- Show trajectory
- Move through the trajectory
- Change bullet speed


Thanks,
B
116
S
48
G
24
Posts: 401
Reputation: 22,207

Post » Thu Jan 14, 2016 8:53 pm

Here's one for the physics behavior:
how-do-i-ball-trajectory-prediction_p983623?#p983623

But you can do it without with simply:

global number gravity=1000
global number speed=200

global number step=0.1
global number vx=0
global number vy=0
global number x=0
global number y=0

every tick
--- dot: destroy
--- set x to cannon.x
--- set y to cannon.y
--- set vx to speed*cos(cannon.angle)
--- set vy to speed*sin(cannon.angle)

repeat 100 times
--- add gravity*step to vy
--- add vx*step to x
--- add vy*step to y
--- create dot at (x,y)
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Thu Jan 14, 2016 9:51 pm

@R0J0hound

You example seems to be very simple but I not sure where to add things to.
Here is my capx for your reference https://www.dropbox.com/s/19z4n8iocakmxsq/trajectory-movement.capx

Also, can I change where the bullet start the movement (x,y)?

thanks,
B
116
S
48
G
24
Posts: 401
Reputation: 22,207

Post » Fri Jan 15, 2016 6:59 am

I can't open your capx atm, but the every tick event is where you set the starting X,y, and velocities. In what I typed about it uses a object called cannon's position and angle.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Fri Jan 15, 2016 4:08 pm

Ok @R0J0hound. I few more questions.
1) The ball should have which behavior?
2) what triggers the ball to start moving?
B
116
S
48
G
24
Posts: 401
Reputation: 22,207

Post » Sat Jan 16, 2016 6:38 am

1) the bullet behavior would work fine.

2) just set the bullet's speed angle of motion and gravity, but you could do whatever.
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, facecrime and 8 guests