- Home /
collisions in character not working!
hello, in my scene i have one character that is almost a cube and its a rigidbody and i need to detect where its colliding in a 2d view so i need to get bottom,left,right and top what i did first since the character is exported from 3dmax and the x,y,z are different i put it in a gameobject, and then i put 4 gameobjects in the char 1 for each different collision and inside those game objects i put a box collider and 1 script the script is the following
public class HitDetection : MonoBehaviour
{
void Update()
{
//this one works
//Debug.Log("Hit!! Update!");
}
void OnCollisionEnter(Collision other)
{
Debug.Log("HIT!!1");
}
}
and its not doing anything... when i use a debug.log in update it works but not this way and also the collisions are actually working because my character looks like its floating because of the box collider i put in the bottom and same for the others so any idea why this is not working?
OnCollisionEnter only happens once per collision (as long as the object doesn't leave at any point). Try using OnCollisionStay, and see what that does.
yeah it doesn't work somehow i think the problem recides because im using a rigidbody as a parent and those collisions are differents from the box collision ty anyway
No, the box collider and the rigidbody work together to interpret the collision. The problem, I think, is that the collision messages get passed straight to the rigidbody- you won't get messages directly on the components of the compound collider like that!
ic that actually sounds reasonable but yeah i will try it ty
Answer by juliocrivera1 · Nov 13, 2011 at 04:08 AM
i gave up and just changed from collision to triggers seems like collisions and different game objects or rigid bodies
Answer by juliocrivera1 · Nov 13, 2011 at 04:08 AM
i gave up and just changed from collision to triggers seems like collisions and different game objects or rigid bodies
Your answer
Follow this Question
Related Questions
Empty/Game Object Gets Stuck inside after Colliding with another Object 2 Answers
Destroy on Collision? 1 Answer
How to make a gameObject active triggered by a collision of another? 1 Answer
Find a specific child of a GameObject with the collision data from OnControllerColliderHit 4 Answers
Detect 2D GameObjects when "Colliding" with each other without RB and collider. 1 Answer