The Daily Click ::. Forums ::. Klik Coding Help ::. Stable position for object over another object while using "set angle"
 

Post Reply  Post Oekaki 
 

Posted By Message

hapsi



Registered
  13/11/2003
Points
  775
15th November, 2015 at 15/11/2015 16:48:33 -

This was easier when you only had 32 angles for objects(easier but uglier), i wonder why they didn't add angle/scale stuff at least in mmf1.

Anyway, here is the issue. Lets say the blue square is a car, and the green cross is a bumper. I need a formula that will point out the position where the bumper needs to be, as seen in the image below.

Image

 
[Signature][/Signature]

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
15th November, 2015 at 15/11/2015 19:47:06 -

Get the angle of the object then set the bumper's position to:

X -> CarX + cos(CarAngle) * (Car Length / 2.0)
Y -> CarY + sin(CarAngle) * (Car Length / 2.0)

 
n/a

hapsi



Registered
  13/11/2003
Points
  775
16th November, 2015 at 16/11/2015 11:43:49 -

Thanks! I really don't remember anything from highschool math.

 
[Signature][/Signature]

hapsi



Registered
  13/11/2003
Points
  775
4th December, 2015 at 04/12/2015 12:57:35 -


Originally Posted by -UrbanMonk-
Get the angle of the object then set the bumper's position to:

X -> CarX + cos(CarAngle) * (Car Length / 2.0)
Y -> CarY + sin(CarAngle) * (Car Length / 2.0)


I did this using these formulas:

Always:
-Set (turret) X position to: X( "pl vehicle gunboat" )+Cos(Angle( "pl vehicle gunboat" ))*32
-Set (turret) Y position to: Y( "pl vehicle gunboat" )+Sin(Angle( "pl vehicle gunboat" ))*32

The X position works, the Y position had to be modified to ...+Sin(360-Angle( "pl vehicle gunboat" ))..., so now it works, but i have another problem.

There are 2 machinegunners on the gunboat and i tried the same formula with x-y changes to their positions:

Always:
-Set (mgunner) X position to: X( "pl vehicle gunboat" )+Cos(Angle( "pl vehicle gunboat" ))*-37
-Set (mgunner) Y position to: Y( "pl vehicle gunboat" )+Sin(360-Angle( "pl vehicle gunboat" ))*-17
and
-Set (mgunner2) X position to: X( "pl vehicle gunboat" )+Cos(Angle( "pl vehicle gunboat" ))*-37
-Set (mgunner2) Y position to: Y( "pl vehicle gunboat" )+Sin(360-Angle( "pl vehicle gunboat" ))*17

..and now i realized that OBIVOUSLY this is not how it works, so i have the X now, but how do i change the relative Y-position?

Image

 
[Signature][/Signature]

hapsi



Registered
  13/11/2003
Points
  775
4th December, 2015 at 04/12/2015 17:07:06 -

Alright, i got it solved:

Always:
-Set (mgunner) X position to: X( "pl vehicle gunboat" )+Cos(Angle( "pl vehicle gunboat" )+23)*-41
-Set (mgunner) Y position to: Y( "pl vehicle gunboat" )+Sin(360-Angle( "pl vehicle gunboat" )-23)*-41

And +23/-23 vice versa to "mgunner 2"

 
[Signature][/Signature]

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
4th December, 2015 at 04/12/2015 22:09:22 -

Yeah I forgot to mention that sometimes the angles don't translate correctly so you might have to play with the values a little bit. Glad you finally got it!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click