Teleporting mesh on Z axis

At around the 5 minute mark, the instructor changes the Platform Velocity from the 100 on the X axis, to 200 on the Z axis, and the move distance to 500.

I did this, and my cube started teleporting.
Oddly, it worked perfectly fine when moving at that velocity on X and Y axis, but on Z axis it was teleporting no matter what velocity I put in.

I was checking things like gravity, etc… nothing.

It turns out that when putting in the code for GetSafeNormal my Visual Studio Code had autocompleted to GetSafeNormal2D

So if you’re following along and encounter a teleporting object on the Z axis, check that this section of the code isn’t using ‘GetSafeNormal2D’

	FVector MoveDirection = PlatformVelocity.GetSafeNormal();
	StartLocation = StartLocation + MoveDirection * MoveDistance;
	PlatformVelocity = -PlatformVelocity;

Just thought I’d help anyone that may encounter this!

Privacy & Terms