Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: blackant on June 07, 2024, 05:42:32 AM

Title: Align GameObject To Normal
Post by: blackant on June 07, 2024, 05:42:32 AM
Hello,

I'm trying to follow a tutorial for car racing.

Becaus it's write in C# it's a bit different from playmaker approach, especially when it comes to this particular point about quaternion orientation.

Here is the code used to align the GameObject to the surface Normal:
Code: [Select]
[b]transform.rotation = Quaternion.FromToRotation(transform.up, hit .normal) * transform.rotation;[/b]
And the transcription using the Actions attached.

The problem is that multiplying the Quaternion is resulting of an infinite rotation over the X axis, not Y.

Any tips about that ?

Title: Re: Align GameObject To Normal
Post by: blackant on June 07, 2024, 07:25:40 AM
For now, the best practice I get can allow me to rotate the GameObject on his Y Axis, but unfortunately this look more as a World Axis than the Local Axis.
And if I release the Key, the GO return back to his initial rotation (0,1,0) converted to Normal direction.

The screenshots bellow
Shows the actions re-ordered, and the max rotation angle his defined by the multiplicator Value of the Input.

Title: Re: Align GameObject To Normal
Post by: blackant on June 07, 2024, 07:42:53 AM
I got a better result reordering the actions and separating the Axis X and Z to apply it on the GO before I rotate it.

But the Angle is Still the same and it breaks the effect
Title: Re: Align GameObject To Normal
Post by: blackant on June 08, 2024, 01:49:35 PM
I Finally decided to write my own action to solve this problem.
I'm Sharing it with you, the code is not cleaned, I made it quick.
So you may use it and use Rotate action before to be able to rotate the model following the normal orientation.

If Jean would like to add it to Ecosystem it's ok.

Sheers. :D