How do I make 0 degree point North and not Right.

0 favourites
  • 11 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hi

    I am building a ship game and for that it would be really useful if could make rotations point up, and not right, when at 0 degrees. Any suggestion? It driving me mad and I have been searching high and low, but cannot find any information on how to do that.

    It goes for Wind direction and for Ships rotation. Need it all to give me true North. Read in tutorials for other engines that talks about "adding" -90 degrees to rotation output but completely lost in where and how to do that. I guess with a system expression or a function? And wouldnt that mess up the CustomMovement behavior I have added ?

    Any suggestions would be much appreciated.

    Regards

    John

  • If you rotate the boat sprite in the sprite editor so it points up there. Then it will point up at 0 degreees in game. Or are you looking for something else?

    Or if you are setting the ship rotation by a windDirection variable then you can simply add -90 to the action where you set the angle instead.

    For example: every tick > set angle to > windDIrection-90

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Would setting the layout or later rotation to -90 at the start of the layout work? You may need to make the layout scrolling unbounded.

  • Thanks for the input so far, really appreciate it!

    • Rotating the sprite wont work as I will put on a either a Bullet behavior or a customMovement (not decided yet) but it would make my ship go sideways.
    • Not sure about using a variable to set the wind direction but will experiment with it.
    • Tried rotating the layout at start of layout but didnt work, since the numbers are the same. I mean the wind direction was now correct but the ship is 180 degrees wrong. Wondering if i can make the bullet behavior work to go backwards etc. This migh actually work.

    But after some thought, I will drop it since, its not really part of the core game play. But if I implement it later i will just do it in the Texture rather than by the numbers. But it still bothers me that I cant do it. At least for now.

    But im still listening if anyone has a way, even if its complicated. Happy to learn.

  • Taking a step back you can convert between compass angles and c2 angles with:

    Compass angle = (c2 angle +90)

    C2 angle = (compass angle -90)

    So if you just want to use compass angles with your events every time you just convert it.

    Ex:

    Instead of

    Set angle to 0

    Use

    Set angle to (0-90)

  • Just been playing around with that, and its probably the best compromise so far.

    Thanks!

  • Only problem is when the ship is going right (0 degrees) and I turn left by one degree, the course will be 449. True north/Up is 360. But from Up to left it will go up to 449 before being 90 pointing left.

  • Your bullet angle and ship facing angle can be independent of each other.

    You can set the ship to face the direction you want as Anonnymitet explained and set the bullet angle a different direction.

  • you can do this to put the number back into the 0 to 360 range.

    (ang+360)%360

  • Holy crap, it works and my head just exploded!

    So for anybody looking for this in the future, this is what made it work. The sprite does its thing pointing right, but in the output to the screen (Text object) I make an action like this: (Text Object) Set text to "Sailboat angle:" & (Player_Sailboat.Angle+90)%360

    Didnt know that was what % does!? I consider this solved. How do I tag it solved btw?

    Thanks a bunch for the help, really appreciate it.

  • % gives the remainder after a division. It can be used to loop the numbers:

    0 % 3 = 0

    1 % 3 = 1

    2 % 3 = 2

    3 % 3 = 0

    4 % 3 = 1

    5 % 3 = 2

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