Movement angle

This forum is currently in read-only mode.
From the Asset Store
3D Car Pack 1
$2.99 USD
3D models + Rendered Low-Poly Cars in isometric, top-down, and side angles.
  • 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 ? <img src="smileys/smiley2.gif" border="0" align="middle">

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

    You have to extend it, but this is the main idea.

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

    You have to extend it, but this is the main idea.

    Thanks, but what about physics ?

  • 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.

  • 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.

    Can you please explain this more detailed or make a cap? <img src="smileys/smiley11.gif" border="0" align="middle" />

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > 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.

    Can you please explain this more detailed or make a cap? <img src="smileys/smiley11.gif" border="0" align="middle" />

    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.

  • 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.. <img src="smileys/smiley24.gif" border="0" align="middle" />

    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.

  • 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?

  • 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?

    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. <img src="smileys/smiley32.gif" border="0" align="middle">

    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 <img src="smileys/smiley4.gif" border="0" align="middle">

    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. <img src="smileys/smiley19.gif" border="0" align="middle">

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)