- Home /
Unity, Prefab Collision not working
Hi, I am making a top-down 2D car game using random amounts of random prefab cars. They are instantiated with the following code:
var newCar : GameObject = Instantiate(carType, pos, Quaternion.Euler(Vector3(0, 0, rotation)));
carType equals to a randomized prefab, position is a random of X amount of spawn locations and the rotation is based on the position. However, when two cars are driving into eachother they just go through eachother, with no collision. They all have the components Rigidbody2D and BoxCollider2D. I am controlling their movement with this:
rigidbody2D.velocity = new Vector2(0,speed);
The plan is to use Animations to handle the turns in an otherwise very gridlike road structure, meaning the roads are paralell with the X and Y axis apart from the intersections.
I also want these crashes to look natural physicswise, perhaps is there a better way to do the manouvering of the cars rather than velocity?
Your answer
Follow this Question
Related Questions
Is it safe to animate collision boxes? 3 Answers
boxcollider fixed bounds 1 Answer
Trigger script does not work. 1 Answer
Is it possible to scale one face of a box collider?? 2 Answers