Collision not working on colliding object rotation vector3
Working on a 3D game, and having issues with the colliders.
Cube Controller has movement input by keyboard, with collider and rigidbody. Cylinder objects have basic colliders and rigidbodys attached; main cylinder has a custom script that rotates the child objects (which have colliders and rigidbodys attached). Rotation script is a basic vector transform on the y axis.
When the Cube collides with the stationary Cylinder, it collides as expected. However, when the Cube collides with the rotating child cylinder, there is a mixed variation. Moving in opposite direction collision allows Cube to fall through Cylinder collider; moving in same direction causes Cube to collide normally.
Can anyone help explain how and why this type of behavior happens, and what I can do to correct it?
I have uploaded a video and screenshots here ::: https://imgur.com/a/PczXJtP
Here is the collision script :::
void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == "Diamond") { AudioSource.PlayClipAtPoint(DiamondGetSound, collider.transform.position); Destroy(collider.gameObject); numDiamonds++;
}
else if (collider.gameObject.tag == "Obstacle")
{
obstacleCounter ++ ;
AudioSource.PlayClipAtPoint(BumpSound, this.transform.position);
Vector3 force = collider.rigidbody.velocity.normalized * (forceFromCollision*10);
collider.rigidbody.AddForce(force,ForceMode.Impulse);
trans = transform;
thisRB = trans.GetComponent();
Vector3 directionToObject = thisRB.position - trans.position;
//adding these bottom two lines from unity documentation, seeing how it effects cube movement with rotating platforms
Vector3 m_Input = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
m_Rigidbody.MovePosition(transform.position + m_Input * Time.deltaTime * m_Speed);
}
... EDIT 3/3/22 even with the help from https://gamedev.stackexchange.com/questions/199607/object-rotating-with-transform-rotate-passes-through-other-collider I have not been able to fix. Requesting additional help.
Your answer
Follow this Question
Related Questions
player going through walls even though it has colliders and rigidbodies 0 Answers
Collider ClosestPoint and ClosestPointOnBounds are just returning the point I pass them? 0 Answers
Spawned objects sink through ground, when over 3 clones 0 Answers
How i prevent 2 obejcts with kinematic checked in both rigidbodies collide? 3 Answers