I have a player character, made of some cubes, spheres and a capsule. I created the empty object Player
and all body parts of the player are a child of Player
. I have two planes, with a moving platform in between. I can walk and jump on the normal planes and the walls, but when the player is on the moving platform the bodyparts of the player fall apart. Maybe it's something really stupid, but I just started with Unity.
This is what goes wrong, the player falls apart on the moving platform: http://nl.tinypic.com/r/207s3sz/9
And below the information about the overview, the player, the body parts, and the moving platform with according character-holder. All bodyparts have the same properties as the body
part on the screenshot. Can anyone help me with what goes wrong here? How can I transport the whole player by the moving platform?
HoldCharacter script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HoldCharacter : MonoBehaviour {
void OnTriggerEnter(Collider other) {
other.transform.parent = gameObject.transform;
}
void OnTriggerExit(Collider other)
{
other.transform.parent = null;
}
}
You just need to disable the
isTrigger
flag. Here are some insightsso how Is Trigger works is that... it will fire
OnTriggerExit
andOnTriggerEnter
, but it will let the object go through it. If you disable theIsTrigger
, then you need to move the logic toOnCollisionEnter
onOnCollisionExit
methods. If the isTrigger uncheck kind of worked, maybe is just the fact that you move the logic for HoldCharacter toOnCollisionEnter
andOnCollisionEnd
respectively Like this:Regards