What's the difference between "Forwards" and "Self.Angle"

Get help using Construct 2

Post » Wed Apr 15, 2015 9:08 pm

I'm reading through the Asteroids Clone tutorial (in under 100 events).

I notice that to accelerate the player's ship we do this:
Accelerate CustomMovement 100 at angle Self.Angle

I also notice that to decelerate the player's ship we do this:
Accelerate CustomMovement Forwards -100

What's the difference between "Forwards" and "Self.Angle"?

Thank you,
-copilot
B
6
S
2
G
2
Posts: 6
Reputation: 1,464

Post » Wed Apr 15, 2015 9:35 pm

There shouldn't be a difference. Why the person who wrote the tutorial used both, I wouldn't know.
Moderator
B
111
S
41
G
20
Posts: 1,586
Reputation: 19,046

Post » Wed Apr 15, 2015 9:38 pm

I tried replacing "Self.Angle" with "Forwards" in this statement
Accelerate CustomMovement 100 at angle Self.Angle

When I do that, the object just moves right, regardless of whether it is rotated. That's what's puzzling me.
B
6
S
2
G
2
Posts: 6
Reputation: 1,464

Post » Wed Apr 15, 2015 9:59 pm

Here's a link to an example capx

(sorry I need to split the URL below because it does not allow me to insert links into forum posts yet - I don't have enough reputation).

https://
www.
dropbox.com/s/zrf370vwz6mqdm6/DifferenceBetweenForwardsAndSelfAngle.capx?dl=0


If you press "w" the player accelerates to the right.
If you press "left arrow" the player rotates counter-clockwise.
If you press "up arrow" the player accelerates toward self.angle.

If you try pressing "w" then "left arrow" and then "up arrow" you'll see the player move in the direction the player is facing.

If you try pressing "w" then "left arrow" and then "w" you'll see the player continue to move right regardless of where the player is facing.

So, there's clearly a difference between the two. I don't know what "Forwards" keys off of. It can't be the angle. Perhaps it's just the direction of the sprite when it was inserted into a layout?
B
6
S
2
G
2
Posts: 6
Reputation: 1,464

Post » Wed Apr 15, 2015 10:02 pm

In simple words,
There are two angles (like in bullet behavior) one is responsible for displaying a rotation of the sprite and second one for moving it.
At start of the game angle of motion for this sprite is 0 - that's why if you set "Accelerate CustomMovement Forwards 100" it will only go right - check the vectors in debugger.

But if you need to move in a direction then you need to specify the speed and direction (angle of motion) - Accelerate CustomMovement 100 at angle Self.Angle.
ImageImageImageImage
B
155
S
61
G
41
Posts: 2,577
Reputation: 34,324


Return to How do I....?

Who is online

Users browsing this forum: Magistross, TRMG, zenox98 and 1 guest