- Home /
Collision between Character Controller and another object sends other object flying
This is a weird one. For some odd reason every time my Player Obj collides with the sides or at times the bottom of another object, the other object is sent flying or gets sucked into the player object.
What would be the causes of this? And is there anyway to fix this?
This is the collision script. The parenting on Player to Platform also does not seem to work properly.
using UnityEngine;
using System.Collections;
public class AllCollisionScript : MonoBehaviour
{
public AllSpawnScript ss;
void OnCollisionEnter(Collision other)
{
if (other.collider.tag == "Platform")
{
ss.tList.Remove(ss.PlatformOBJChild);
GameObject.Destroy(gameObject);
Debug.Log("Resetting Platform!");
}
if (other.collider.tag == "PlatformEnd")
{
ss.tList.Remove(ss.PlatformOBJChild);
GameObject.Destroy(gameObject);
//Debug.Log("Platform reached END");
}
if (other.collider.tag == "Player")
{
Debug.Log ("Is Parented");
ss.PlatformOBJChild.parent = ss.PlayerOBJChild;
}
else
{
return;
}
}
}
OnCollisionEnter
is not called for character controllers. You must have something else you are not showing
I don't have much for the collision script. I just finished adding in raycast collision but since the platforms are long the raycast doesn't seem to hit.
EDIT: OH WAIT! Dude, I have NOTHING else. That's the problem.
How do I get collision from a character controller?
Is there a collider on your character controller and a rigidbody on either the controller or the object being hit?
Player has a RigidBody, object being his has a collider and a rigidbody.
I used OnControllerColliderHit and that gave me somewhat the results I wanted.
So... I then checked my rigidbodies and froze all the XYZ, now that gave me more of what I wanted BUT the character falls through.
I froze them on both the Player and Object hit.
Typically you don't have a collider or a rigidbody on the same game object that has a character controller. $$anonymous$$ake sure your character starts a bit above the floor, and that the floor has a collider.
Answer by imaginationrabbit · Jan 09, 2017 at 11:37 AM
I made a script that is rough but solves this issue- you can find it here link text
Your answer
Follow this Question
Related Questions
How to parent gameobject at point of collision? 0 Answers
[VIDEO]how to collision.transform.parent = transform.position ?(Parenting) 1 Answer
Parenting ethans hand to a gameobject 0 Answers
Parenting after X time with collision, I dont get it! 1 Answer
Help with collision detection with specific colliders 1 Answer