How do I create an object in the direction of another object's angle

  • So if Object_1 is at a 90 degree angle, I want to create Object_2 50 pixels away in the direction that Object_1 is facing.

    Sorry if there's a simple answer but math and angles aren't something I know a lot about.

    Thanks for any help

    Tagged:

  • Nevermind I found a solution from a post I made years ago and forgot about.

    In case someone else stumbles on this and wants to know here's the solution:

    Give Object_1 the Sine behavior.

    When you create the Object_2, set the coordinates to:

    X: Object_1.X+cos(Object_1.Angle)*(Object_1.Sine.Value+50)

    Y: Object_1.Y+sin(Object_1.Angle)*(Object_1.Sine.Value+50)

    That's it. If you want to change the distance just change the number after Sine.Value

    Hope this helps someone!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why do you need Sine behavior?

    Another (easier) solution is to create Object2 at Object1 position, and then move it 50px at Object1.angle (using the action "Move at angle")

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