Hey guys I’m a student and very new to unity, so please excuse my n00bness.
Basically, my game’s character has a constant force added to it, as well as no gravity to make it move forward. Directional keys are added to this object allowing the user to steer left and right. The outline of the game is to control the “car” with the force attached to it and guide it along a straight road, dodging rubbish bins and other obstacles that get in the way.
Anyway, the problem i’m having is when the “car” (players object) hits an obstacle at speed, it’s registered that it has collided, but it bounces off and just floats away since I haven’t added gravity to it. (when I add gravity to it, my player object doesn’t move anywhere). What I want the player object to do is be able to collide with an obstacle, register the collision (which it is doing) but without changing its route/path. Both the player and the obstacles have rigidbodys. Sorry this is long-winded, I hope you can help!
You could possible check the Is Kinematic variable on the rigidbody component, and Is Trigger on the collider component of the props. I can’t be sure of this but I think when Is Kinematic is checked the object is no longer calculated by the physics engine, and when Is Trigger is checked it means the collider is only used for returning an event and not calculating physics.
I have just tried this out on my obstacle object and my car object just seems to go through it without any collision at all? What i’m look for is there to be a collision from both the obstacle and the car, but this collision does not effect the route of the car.
I have checked ‘freeze rotation’ on the car object’s rigidbody as a bid to help, but i still find the car floats upwards since gravity isn’t checked.
right, of course your car goes through the obstacles now, you disabled the collision! You need to make a script that slows/stops your car, applies damage or whatever else you need when the collision event is triggered. If you don’t want to code something like that, then i suppose you could set your gravity to the z axis (instead of the y) and your car will bounce off of obstacles like i think you want. You can change the axis of gravity in the physics settings.