I have got my player controlling working out decent enough, except with mediocre animation controller for the player, but oh well. All I have done so far is basic input: move, run, jump, multi-jump. How would I approach making my player conform to the movement of the moving platform. I know to move the platform relative to my player on top of adding more force if player has moved. I have looked up some resources on line, but I am confused why they use certain methods.
def Platform ():
//BROKEN
if (activePlatform != null):
newGlobalPlatformPoint = activePlatform.TransformPoint(activeLocalPlatformPoint)
moveDistance = (newGlobalPlatformPoint - activeGlobalPlatformPoint)
if (moveDistance != Vector3.zero):
controller.Move(moveDistance)
lastPlatformVelocity = (newGlobalPlatformPoint - activeGlobalPlatformPoint) / Time.deltaTime
else:
lastPlatformVelocity = Vector3.zero
activePlatform = null
if activePlatform != null:
activeGlobalPlatformPoint = transform.position
activeLocalPlatformPoint = activePlatform.InverseTransformPoint (transform.position)
I don't understand why it is important to get local and world positions. Also, I don't understand moveDistance calculation.
My first intuition was doing something like moveDistance.y or moveDistance.x and changing them depending on the hit object positive or negative velocity. Just getting some ideas.
I also use:
def OnControllerColliderHit (hit as ControllerColliderHit):
if (hit.moveDirection.y < -0.9) & (hit.normal.y > 0.5):
activePlatform = hit.collider.transform
to check which platform I have collided with and strictly focusing on the one below the player.