How do I implement rotating the environment and have working solid collisions?

0 favourites
  • 6 posts
  • I've been trying to create a game that allows the player to rotate their environment. I've been able to do this by having the needed layers in my project rotate. However, some problems came from this, most notably from trying to move using the behavior 8 direction (It would not keep moving in the direction up when rotating the environment.) Thus I went to use the custom movement option and that mostly worked besides the solid collisions. Now whenever colliding with solids the player will move in certain directions. (Like when colliding with a solid from the solid's left side results in moving down even if you are moving only moving right.) Does anyone know how to fix this issue or is this an issue with the construct? Because I've also noticed that characters will move slightly in one a direction at around something like 1x10^-14. I've noted my findings in the .cp3 file as well. The construct 3 documentation doesn't really shed light on this topic and I couldn't find any topics specifically pertaining to my question. Again does anyone have ideas to fix the player moving in weird directions while still keeping the ability to rotate the environment please?

    Here is the .cp3 file

  • Use the 8-direction behaviour and put your player object on a separate layer that you don't rotate. If you want the player to rotate with the other layer then make the player object invisible and pin a second object to it which you rotate at the same time as the other layer.

    That said, it's not uncommon to have the up arrow mean "move Forward" and the left and right keys mean "turn left" or "turn right" which would mean that you don't need to change anything. You just need a clear visual representation of the direction your character is facing

  • Thanks for the reply

    Doing this solution still doesn't seem to work. the 8 direction behavior moves in a direction no matter what (Left will change the x negatively no matter what the current angle of the layers are.) Separating the layers still doesn't seem to help either as the collisions still are mess up. Except this time the player when the environment is angled will move into objects and teleport around. Do you have any other ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Apologies I didn't think that alternate layer rotation would mess up the 8 direction on another layer.

    Another method would be to use the bullet behaviour and set to bounce off solids.

    Set it to not change the objects angle and when you press a direction key you would set the angle to self.angle(+-desired direction angle)+Camerarotation.


    on left key down - Set bullet angle of motion to: self.angle-180+CameraRotation

  • The custom movement behavior's collision response has always been bugged like that in my experience. aka it tends to a certain direction.

    I have a few ideas how you can do what you want.

    One I tried was to keep using the 8 direction behavior and put the player on a different layer that isn't rotated. but the motion was still oriented to the layout. Setting the parallax to 0 for the layer that the player was on just did some wonkiness.

    A second idea could be to do the motion with events and just use the 8dir behavior for collision response. Here's some events that replicate the 8 direction motion but lets it be in relation to the object's angle. This was an older example and i didn't make a complete test for your setup.

    Another idea, that i ended up testing, was to just use 8 direction and rotate all the other objects around the player. It seems to work well and is fairly simple. Just have to duplicate some actions for each object type you want to rotate.

    On a side note it's possible to cut out the 8direction behavior completely to get stuff like wall sliding. But that's not exactly related to your post.

  • Thanks again everyone for the responses

    Trying all the different options it seems like calminthenight's second suggestion would work best for the game I'm creating. Although the colliding with a solid makes the player move faster it seems sufficient enough for me. R0J0hound's suggestion on having everything revolve around the player does seem to work great until the map size becomes larger and the objects/solids get sent away from their original positions. Which, means that sometimes the objects will reach the edge of the layout making it impossible to see thing (At least in the testing I did.)

    Thank you all for responding!

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