Movement angle

For questions about using Classic.

Post » Fri Feb 10, 2012 5:05 pm

Hello guys. I want my character to change angle while moving on up the mountain (climbing). For exampe ive got this terrain and my character does not change his angle while moving up or down. I did this with masks, but this is very difficult and i think this could be done more easily with physics behavior. Can someone plz help me with this problem ? eony321v2012-02-14 17:23:32
B
20
S
5
G
4
Posts: 39
Reputation: 3,898

Post » Sat Feb 11, 2012 1:10 am

http://dl.dropbox.com/u/2721498/2stroke/Construct/cap/terrain%26angle.cap

You have to extend it, but this is the main idea.
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Sat Feb 11, 2012 5:08 am

[QUOTE=Pecek] http://dl.dropbox.com/u/2721498/2stroke/Construct/cap/terrain%26angle.cap

You have to extend it, but this is the main idea.[/QUOTE]
Thanks, but what about physics ?
B
20
S
5
G
4
Posts: 39
Reputation: 3,898

Post » Sat Feb 11, 2012 11:38 am

I don't really know the Physics Behaviour that well, but from what You are saying, it sounds like moving up a slope is no problem for You? Just adjusting the angle of the Player Sprite itself (the rotation)?

You can easily do this by comparing the LastX and LastY (private variables, that You assign the .X and .Y position to, at the end of the Event Sheet) position with the current .X and .Y position, by entering the values into the angle expression (a system expression).
It will then give You the angle the Player is moving in; You then just set the Player Sprite Angle to this.Shindoh2012-02-11 11:39:42
B
3
G
1
Posts: 70
Reputation: 615

Post » Sat Feb 11, 2012 11:59 am

[QUOTE=Shindoh] I don't really know the Physics Behaviour that well, but from what You are saying, it sounds like moving up a slope is no problem for You? Just adjusting the angle of the Player Sprite itself (the rotation)?

You can easily do this by comparing the LastX and LastY (private variables, that You assign the .X and .Y position to, at the end of the Event Sheet) position with the current .X and .Y position, by entering the values into the angle expression (a system expression).
It will then give You the angle the Player is moving in; You then just set the Player Sprite Angle to this.[/QUOTE]

Can you please explain this more detailed or make a cap?
B
20
S
5
G
4
Posts: 39
Reputation: 3,898

Post » Sat Feb 11, 2012 9:31 pm

Physics on uneven terrain is a bit tricky, since it's doesnt use a per pixel collission, you have to set the collission masks by hand.
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Sun Feb 12, 2012 1:27 am

[QUOTE=eony321v] [QUOTE=Shindoh] I don't really know the Physics Behaviour that well, but from what You are saying, it sounds like moving up a slope is no problem for You? Just adjusting the angle of the Player Sprite itself (the rotation)?

You can easily do this by comparing the LastX and LastY (private variables, that You assign the .X and .Y position to, at the end of the Event Sheet) position with the current .X and .Y position, by entering the values into the angle expression (a system expression).
It will then give You the angle the Player is moving in; You then just set the Player Sprite Angle to this.[/QUOTE]

Can you please explain this more detailed or make a cap? [/QUOTE]
Okay, the basic idea behind finding an angle is having two points at different positions.
Imagine a coordinate system, a graph. Now You enter a point at (5, 5) -> (X, Y). The point is at 5X and 5Y in the coordinate system. Now let's make a second point at (10, 10). It should already be obvious when looking at this graph, but then You connect the two points.
Now relative to the X and Y axis, that means, when You compare the line You just drew to the X-Axis and the Y-Axis, it will be 45 degrees.
You could get the same result, by entering a point at (0, 0), and (1, 1), this would also equal a 45 degree angle.

So what we need first is two points to compare, the last position, and the current position of Your object. In the current tick (the current frame of the game), how do we get the last position?
First we give our object two private variables, a LastX and a LastY variable. Then we need to assign them. Now we want to have the old value, before any new movement is added in the Event List.
If You were having Events further down Your Event List, that move the Object, we could just assign the current .X and .Y position to LastX and LastY at the top of the Event List.

See it this way, the Event List is checked from top to bottom.
Now, it will first fill the LastX and LastY variable with the current .X and .Y (let's say 5X and 5Y), further down You have an Event moving the object to the right (X+5) and up (Y-5). So now the current .X and .Y position in this frame, this tick the Event is checked, is 10X and 10Y, while LastX and LastY are still 5X and 5Y.
So below the Event for movement, we can now compare the two. Because LastX and LastY will only be assigned again in the next frame/tick of the game (at the top of the Event List). But in the current tick, it hasn't been changed yet.
B
3
G
1
Posts: 70
Reputation: 615

Post » Tue Feb 14, 2012 3:08 pm

wanted to bump this because im still struggling with the same problem.
hey shindoh, is there any chance you could do a simple barebones example for what you just explained? im still not quite sure if i get it right.

also, i tried experimenting with that example pecek posted, but it didnt work properly with a dummy physics object. there was some strange angle jerking issues i couldnt really solve. i guess it had something to do with picking and different objects..

id like to be able to get the player angle right whether im touching a floor, ceiling, wall or a curved slope, but im kind of stuck as of now.
B
1
Posts: 7
Reputation: 239

Post » Thu Feb 16, 2012 10:12 am

Here's an example: http://www.filedropper.com/angleupdateexample
This will adjust the angle of the sprite according to the current movement angle.

I'm sorry it took so long, but I'm in China right now, and almost every foreign file/image/video upload as well as streaming website is blocked here.
I also only just now saw Your terrain sprite. Are those small pixels floating in the air near the terrain also part of the terrain sprite?
B
3
G
1
Posts: 70
Reputation: 615

Post » Thu Feb 16, 2012 1:22 pm

[QUOTE=Shindoh] Here's an example: http://www.filedropper.com/angleupdateexample
This will adjust the angle of the sprite according to the current movement angle.

I'm sorry it took so long, but I'm in China right now, and almost every foreign file/image/video upload as well as streaming website is blocked here.
I also only just now saw Your terrain sprite. Are those small pixels floating in the air near the terrain also part of the terrain sprite?
[/QUOTE]

thanks so much for the example, its pretty much just the thing i was looking for, and pretty simple too. once again, i was making simple things too complicated.

however, after fiddling around with that .cap, i realized i need to do some stuff differently. i made a simple loop and i pretty much have to make a new method of moving across the floor to make the (half)loop smooth to travel. i made an object on a hotspot thats locked to the characters angle and i give physics object force towards that object, so now it gets force to a right direction when traversing the loop (kinda similar to fancy pants- game, where theres alot of loops).
HOWEVER, problem is, how can i make it go the other way?
since the object changes direction when the "character" turns. so now, only right arrow makes the physics object to go both direction?

wall o' text, sorry. anyway, in short, i made a simple .cap of the problem:

http://dl.dropbox.com/u/11157144/movement-angle-test.cap

once again, thanks for helping me out, now i can get a little further again


TINY EDIT: also, i ran into this little issue,where the angle isnt showing properly when traversing upside down. maybe this picture eplains it better:




i cant really figure out a workaround to this. dolphyn2012-02-16 22:19:09
B
1
Posts: 7
Reputation: 239

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest