recreating the pin behavior plus a little more?

For questions about using Classic.

Post » Tue Jan 17, 2012 7:11 am

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?
B
5
S
1
G
2
Posts: 99
Reputation: 1,575

Post » Tue Jan 17, 2012 8:12 am

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.captulamide2012-01-17 08:17:38
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu Jan 19, 2012 2:06 am

Gosh that's a lot of work... I'm starting to think maybe I will just make my game more simple. Thank you!
B
5
S
1
G
2
Posts: 99
Reputation: 1,575


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests