How could I make bullets do this?

Discussion and feedback on Construct 2

Post » Fri Sep 11, 2015 7:58 pm

Hello Constructors,

I've come to regret not studying harder at math in high school. I'm trying to figure out how to shoot three bullets that arc upwards at three different angles:

Image

• The red bullet rotates to a 90 degree angle after 1 second of forward momentum
• The green rotates to an 80 degree angle after 2 seconds
• And the blue to 70 degrees after 3 seconds

If anyone has any clues on equations or construct methods, I'd really appreciate it.

Thanks!
B
20
S
5
G
3
Posts: 66
Reputation: 2,823

Post » Fri Sep 11, 2015 8:14 pm

The one formula to know for motion is:
speed*time=distance

Take the red bullet as and example. You know the time (1 second) and the distance (90 degrees). so the equation is:
speed*1 = 90

You want to know the speed of the rotation so isolate speed on one side and we get:
speed = 90/1
or
speed =90

then you can do the motion with an event like:

every tick:
--- rotate red 90*dt degrees counter-clockwise
--- rotate green 40*dt degrees counter-clockwise
--- rotate blue 70/2*dt degrees counter-clockwise


My next question is do you want the bullets to continue turning after that of just continue straight?

If continue staight use "rotate toward angle" instead.
B
91
S
31
G
103
Posts: 5,241
Reputation: 67,768

Post » Fri Sep 11, 2015 8:50 pm

I think you misread his question a bit R0j0hound. The duration he stated are for forward momentum only. There is no talk of arcing duration nor speed, he should probably specify those as well to get a better answer.

I'd say set a timer on each bullet and start arcing when the forward movement is done, by applying a "rotate toward angle" action every tick as R0J0 said. (with an angular speed yet to be determined)
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Fri Sep 11, 2015 9:02 pm

Ah, true. I missed that forward momentum bit.
B
91
S
31
G
103
Posts: 5,241
Reputation: 67,768

Post » Fri Sep 11, 2015 9:15 pm

This is all fascinating and very helpful! Thanks so much to you both for taking the time, especially with helping me understand the formula. Teach a man to fish, as they say. I was indeed intending on the bullets continuing forward while bending; my fault for not being specific. Gameplay may change that, though. This is just my pencil sketch. Anyway I'll give it a crack this weekend and report back. Thanks again!
B
20
S
5
G
3
Posts: 66
Reputation: 2,823

Post » Fri Sep 11, 2015 11:56 pm

Following R0J0hound's and Magistross's instructions, I made an example capx: https://www.dropbox.com/s/vag52wm4u25qk ... .capx?dl=0

You'll need C2 version 212.2 in order to open it.
composer - multimedia artist
www.eli0s.com/en/
B
68
S
26
G
4
Posts: 1,146
Reputation: 9,649

Post » Sat Sep 12, 2015 12:07 am

You want bullets that fly straight for some time then change course?

For the bullets, add a instance variable, call it:

IsTurning=0

Then use On Create(Bullet) -> wait (time that you want bullet to go straight) -> set IsTurning=1

Bullet (Compare Instance), IsTurning=1 -> Rotate towards whichever direction.

It's what I use for my missiles in Star Nomad 2, when you launch it, it flies straight for some time (adding ship velocity) before activating the thruster & target seeker AI.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Tue Sep 15, 2015 10:41 pm

Thanks to you all — mission accomplished!

Really appreciated the capx and the math tutorial; it's helping with other angular bullet ideas.

Looking forward to Star Nomad 2!
B
20
S
5
G
3
Posts: 66
Reputation: 2,823


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests