- Home /
player script affects back and front of box collider
hey guys I am making a futuristic racing game. Anyway the script I made for the Player's ship is affecting the front and back of the ship's box collider, it causes the ship to phase through the wall whe ncolliding with it head on or when reversing, hitting the walls front the side is fine. How could I edit my script to fix this?
var speed : float = 10.0;
var turnspeed : float = 100;
var thrustForce: float;
function Update (){
thrust = Input.GetAxis("Vertical");
turn = Input.GetAxis("Horizontal");
transform.Translate(thrust*Vector3.forward*Time.deltaTime*speed);
transform.Rotate(turn*Vector3.up*Time.deltaTime*turnspeed);
}
I don't think this is a script issue. Are you using a rigidbody? Is it set to kinematic? How is the ship setup is what we need to know.
Answer by unity_oEoMzC5COK722Q · Dec 23, 2018 at 04:52 PM
This usually happens when your gameobject has a rigidbody component and you try to manipulate its position using Transform.Translate. If your gameobject indeed does have a rigidbody, you need to move it around using Rigidbody.MovePosition. Otherwise the collision system is not going to work as intended.
Your answer
![](https://koobas.hobune.stream/wayback/20220612184444im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Look at script wrong at high speeds 0 Answers
stop vehicle from moving through walls 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Making a bubble level (not a game but work tool) 1 Answer
Movement animation 1 Answer