0 Favourites

recreating the pin behavior plus a little more?

This forum is currently in read-only mode.
  • I want to preserve an objects relative position and angle to another object, but I want that first object to be the player, and I want the other object to be a platform that moves in every direction and rotates at every angle. The player's position and angle to this platform would only be preserved while in a specified area (an area on and above the platform)...

    I have tried adding the X and Y vectors of motion of the platform to the players, but this doesn't work when the platform starts rotating.

    Any suggestions or hints?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • No specific help this time, I'm afraid, but in general you'd use sin and cos with values like distance and angle between points.

    For example, if the position of objectA is [50, 100] while the position of objectB is [200, 200] and the angle 0?, and you are now about to rotate objectB to 15?:

    radius = distance(objectA.X, objectA.Y, objectB.X, objectB.Y)

    relativeAngle = angle(objectB.X, objectB.Y, objectA.X, objectA.Y)

    objectA's new rotated x = objectB.X + cos(relativeAngle + 15) * radius

    objectA's new rotated y = objectB.Y + sin(relativeAngle + 15) * radius

    Now that objectA is repositioned you can rotate objectB to 15?.

    You need to work with buffers (pv for every value) when at the same time you not only want to rotate objectB, but move it also.

    Then you would buffer distance and angle before moving objectB, then move objectB, then calculate objectA's new position and finally rotate objectB.

    EDIT

    Very, very simple example cap: rotating_relative.cap

  • Gosh that's a lot of work... I'm starting to think maybe I will just make my game more simple. Thank you!

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