- Home /
Unstick from platform
ok, I have been to a number of sites that all seem to give the same script. I followed the simple video tutorial to the letter..and sure enough it works wonderfully as far as getting my character to ride the platform. but he is unable to walk around on the platform - he is literally stuck to it. not that I mind that so much - but the part about getting the character OFF the platform doesn't work and I have no clue as to why. looking at the script and with my little understanding...it seems like the parenting is null ON TRIGGER EXIT, but if my character is stuck on the platform how can he trigger exit. a Catch 22. I am not moving the platform with script. I tried animating it in Unity as well as an external 3D program and imported the fbx. I'm doing something right as the first part of the script works
using UnityEngine;
using System.Collections;
public class HoldCharacter : MonoBehaviour {
void OnTriggerEnter (Collider col) {
col.transform.parent = gameObject.transform;
}
void OnTriggerExit(Collider col){
col.transform.parent = null;
}
}`
If the character is unable to perform any action once on a platform, I assume that the CharacterController does work with the platform. Perhaps, this is just a layer issue, and the CharacterController does not recognize the platform as walkable.
I'm with you here. I have used the same script and my character sticks to the platform and is able to move around on it on entry, but when the platform begins to move the character seems to fall through all of a sudden. very strange.