- Home /
need platforms to move character with them, not take the character through them
i've uploaded my rubik's cube scene here:- http://www.megaupload.com/?d=9OC7306C
now the problem i have with this is, the colliders just don;t work like i want them to!! the character can stand on the box, but if he's next to it and th box moves, the box goes through him!!
in this scene, to test what im talking about, start rotating the top slice of the 5X5 Rubik's cube by pressing 'e' and 'r' (the key to change slices is 'y'). you'll see that the slice rotates, but the character doesn't!! that's problem 1. (i even applied some phyics materials with loads of friction, but it doesn't work)
the second problem is, that when the character is made to stand on the little part jutting out in the slice just below the top slice, while rotating, the slice goes through him!! that's problem 2 (the problem with the collider)
here are the pictures:-
pic 1: Standing on part jutting out
pic 2: after rotation, a cube goes through him, grrrr...
i got this script attached to the character controller, and i have the white cube tagged as 'PlatformX' to work with it, doesn't work!!:-
function Update () { }
function OnTriggerEnter(t: Collider) { Debug.Log("On trigger enter in " + gameObject.name); if (t.gameObject.tag == "PlatformX") { gameObject.transform.parent = t.gameObject.transform; Debug.Log("Parented"); } }
function OnTriggerExit(t: Collider)
{
Debug.Log("On trigger exit in " + gameObject.name);
if (t.gameObject.tag == "Platform")
{
gameObject.transform.parent = null;
Debug.Log("Unparented");
}
}
This script was partly supposed to fix Problem 1 (all i had to do was tag all the platforms 'PlatformX'). Which it didn't. And Problem 2 just baffles me, any ideas????
Answer by spinaljack · Oct 18, 2010 at 01:16 PM
Character controllers don't react to physics, nor do they cause physics reactions in other objects (you can't push a block with just a character controller)
You need to detect collision with OnControllerColliderHit and then make the effects happen by script i.e. move the character away from a moving platform or add force to a block you're trying to push
or use a rigidbody ins$$anonymous$$d of a charactercontroller