AlignToGround after using Teleporter

devomage

Member
I've spent several hours trying to track down how to properly use AlignToGround. I 'think' it is the issue with the attached screenshot. Setting the Transform Rotation on the Destination Transform makes the character permanently rotated. I'm assuming AlignToGround is the culprit because it fixes it if it is "Enabled". But, in the Demo this ability is disabled. Obviously you wouldn't want this on constantly...

I've went through each script attached to Demo Nolan. I believe I have everything identical in my scene. Also, added Debug's to the ability itself and see the Debug firing in the demo with an identical Teleport. The Debug does not fire in the non-Demo scene.

Very frustrating that this is so difficult to track down... even though it is likely a simple fix.
 

Attachments

  • AlignToGround-notfiring.png
    AlignToGround-notfiring.png
    240.7 KB · Views: 9
If you are teleporting to that sphere you will need to ensure an Align to Gravity ability is enabled. In the demo scene the Align to Gravity Zone ability is activated when the character enters the teleporter. There is a State Trigger which activates the AlignToGround state, and this state sets the Align to Gravity Zone to a start type of Automatic.

In the Dynamic Gravity room the Align to Ground ability is used and this ability is enabled similarly with the State Trigger component.
 
The sphere is just visual with no collider and is the Teleporter.cs Destination Transform. I'm teleporting to the platform as shown, that is below the sphere.

The Gravity Zone stuff is required for the Teleporter? I'm even more confused now.
 
The Align to Gravity ability is required if you want to change orientations. The teleporter doesn't require the ability, it just enables the ability so it'll start after the character has teleported.

Since you are teleporting to a non-0 x rotation you'll want to enable either Align to Gravity Zone or Align to Normal after you've teleported.
 
I already had AlignToGravityZone ability configured. I must have already added it trying to debug this problem. I do not see a AlignToNormal script/ability...

edit: attached demo nolan debug showing AlignToGravityZone as the first and last row in the console. AlignToGround is the middle two.

nothing triggers in my demo scene.

What triggers AlignToGravityZone after characterLocomotion.SetPositionAndRotation() is called inside Teleporter.cs?

full disclosure: i do not have any non-zero SpawnPoint's/Destination's. I was interested in @DankP3 Teleport scenario and was testing different things. however, this has now ate many hours of my time with no resolution... im rather invested in a proper answer.
 

Attachments

  • nolan.png
    nolan.png
    16.6 KB · Views: 1
Last edited:
Just tried a brute force and copied the CharacterLocomotion component from Demo Nolan to my character. no change (except for jack'n my smoothed bones).

edit: just copied Demo Nolan to my scene. no change. i've exhausted all my ideas on how to figure this out. attached is a clean repro scene with Nolan.
 

Attachments

  • Teleport_Repro.unitypackage
    152.1 KB · Views: 2
Last edited:
What triggers AlignToGravityZone after characterLocomotion.SetPositionAndRotation() is called inside Teleporter.cs?
Ah, you may be hitting a bug that I ran into where the ability stops too soon. Open AlignToGravity and change the stopping condition within CanStopAbility to:

Code:
            if (m_StopGravityDirection.sqrMagnitude == 0 || Vector3.Dot(m_CharacterLocomotion.Up, -m_StopGravityDirection) > 0.999f) {
 
Ah, now I see what you are doing. In this case you don't want to use any of the align to ground abilities. The character will use the up direction specified by the teleport's destination. Because your destination is rotated it uses that position. The fix is to create a child destination transform that has the correct world orientation. When the character teleports they will then use that world orientation and be upright.
 
this doesnt explain why the Demo works and the repro scene does not. also, your last reply sounds kinda hacky~

either way, this doesnt effect me and i've spent way too much time on it. moving on.
 
Top