- Home /
Pushing a character controller (physics interaction)
Hello, I need for my game, to push the character controller, I have a concave mesh with a mesh collider on it ( you are inside it the whole game) what I want to achieve, is to when you hit that wall, it would push you, just push you regularly, like if both objects had a rigidbody.
 void OnCollisionStay (Collision col) {
     if (col.transform.tag == "Player") {
         CharacterController cc = col.transform.GetComponent<CharacterController>();
         Vector3 dir = transform.position - col.transform.position;
         cc.Move(dir * 5f * Time.deltaTime);
     }
 }
I tried to achieve that effect with that code, I know one thing won't work, I'm using ransform.position - col.transform.position, and I want to use the contact point instead, but I don't know how to make do that. So, do you have any idea how I can make this work, btw the object doesn't move, it scales in instead (so your room gets smaller, so velocity is actually the scaling velocity).
         float distance = Vector3.Distance(transform.localScale, targetScale);
         transform.localScale = Vector3.Lerp(transform.localScale, targetScale, (Time.deltaTime * velocity)/distance);
Thanks in advance.
Your answer
 
 
             Follow this Question
Related Questions
Collision Problem - Floor Button & Character Controller 1 Answer
Character mouvement and collisions in arbitrary angled surface 1 Answer
Character Controller not ground object 1 Answer
Colliders doesn t collide with CharacterController 1 Answer
OnControllerColliderHit won't trigger if not moving 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                