Altering iTween Moving Platforms example using Character Controller?

I recently looked into the Moving Platforms example that is available on the iTween website, mostly because I ran into problems with elevating platforms and my player character occasionally falling through them on the way down.

The example scene solves this by checking whether the player is colliding with one of the platforms, but unfortunately I can’t get this to work with a Character Controller… uh, controlled player since the OnCollision…() functions are not supported by the Controller, while on the other hand isGrounded apparently doesn’t tell me what object the player is grounded on.

Maybe it’s too late in the evening already, but I am unable to find a solution and get this working. I could throw away the Controller and use a RigidBody on my player character instead, but that would mean recoding large parts of what I already have.

Hi!
You have to make your player parent of your platforms:

  • Make a empty gameobject and add a boxcollider on it.
  • Put this new object up your plateform and make it as child of your platform.
  • In the empty gameObject in the boxcollider, check ‘is Trigger’.
  • creat a new javaScript and past the code below
  • drag the script on the emptygameobject

and Voila! :stuck_out_tongue:

var platform : Transform;
var player : Transform;

function OnTriggerEnter(){
	var GO = platform;
	var GO1 = player;
	
	GO1.transform.parent = GO.transform;

}

function OnTriggerExit(){
	var GO = platform;
	var GO1 = player;
	
	GO1.transform.parent = null;

}