Cannot set Bullet "angle of motion" to go up or down

Bugs will be moved here once resolved.

Post » Wed Dec 16, 2015 7:12 am

Problem Description
I Cannot set Bullet "angle of motion" to go up or down, even if I set the Bullet speed first. It can only go left and right.
I ensured that Bullet > Set angle is set to No, but it persists.

Attach a Capx
DEMO: http://naturedumarche.com/block/export/index.html
CAPX: http://naturedumarche.com/block/bulletangleofmotionproblem.capx

Description of Capx
Use WASD and see what happens when pressing A or D; it seems like there is no way I can make the character go up or down using the Bullet behavior. I tried a lot of combinations, I think this is an engine problem (and a basic one, I put as much time trying to fix this than to make the whole project, this is frustrating). I was on an older version so I thought it was maybe normal, so I updated (to v.216), but the exact same problem is still there.

Affected Browsers
  • Chrome: (YES)
  • FireFox: (YES)
  • Internet Explorer: (YES)

Operating System and Service Pack
Windows 7 64-bit SP1
Rendering with OpenGL 4.5.0 nVidia 347.52

Construct 2 Version ID
Release 216 (64-bit)
Built at 13:46:39 on Oct 22 2015
B
9
S
4
G
1
Posts: 18
Reputation: 1,315

Post » Wed Dec 16, 2015 9:11 am

I'm not the dev but here's a quick explanation of what is happening. The behavior doesn't store the angle of motion and speed, instead it stores the horizontal and vertical velocities and calculates speed and angle of motion from them. So when the speed is 0 the velocities are (0, 0) which results in an angle of motion calculated as:
angleOfMotion = angle(0,0, horizontalVelocity, verticalVelocity) = angle(0,0,0,0) = 0

That's why whenever the speed is 0 the angle of motion becomes 0. which happens in your capx when you set the speed to iaccelerate, which is zero at the start of the layout and after hitting a wall.

Anyway's while waiting for an official response you could reproduce the bullet behavior with events. It's rather simple and we can make it keep the angle of motion even when the speed is zero.

1. add two variables to your object of choice (character for instance), and call them "speed" and "angleOfMotion".

2. add an event like the following and put it toward the top of your event sheet. basically jut use the "move at angle" action.
Code: Select all
every tick
--- character: move self.speed*dt pixels at self.angleOfMotion degrees


And that's pretty much it.
B
91
S
31
G
102
Posts: 5,233
Reputation: 67,252

Post » Wed Dec 16, 2015 4:54 pm

Closing, please follow the bug report guidelines and submit a minimal .capx only.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,238

Post » Thu Dec 17, 2015 8:19 am

Thank you very much R0J0hound, I followed your guidelines and it works now. I set and reset the Bullet speed to 1 instead of 0 and it now works :) I don't need to re-open the bug report.
B
9
S
4
G
1
Posts: 18
Reputation: 1,315


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests