Terrain Spins when hit by player
I'm just staring out, so it's probably something simple I'm doing wrong.
Here's my Hierarchy:
Directional Light
Terrain
Cube
Sphere
Cylinder //its my turret
Player
Camera
So if I have a plain flat terrain it works great, but as soon as I add hills it messes up. When my player falls a little onto the terrain, the terrain acts like a rag doll and falls on it's side leaving this weird half spun terrain.
I'm trying to write a basic script for my player which is a cylinder that has a capsule collider and a rigidbody, and mesh renderer. and my script which only says to update this: transform.Translate(Vector3.forward * player_speed);
I have no clue how to fix the terrain getting affected by physics it looks like.
Another thing is that my camera preview parented to my player only shows blue and grey in skybox mode, and nothing else. I have to put it on solid or depth to see my terrain in the camera preview.
Any help is much appreciated, Thanks, Jeremy
Answer by $$anonymous$$ · Dec 03, 2015 at 08:52 PM
Not sure what you are exactly asking for, but have you checked to see if you accidentally dragged a script onto the terrain itself? Also what version of Unity are you using because that can also determine if an update where certain bugs are fixed can resolve problems.
Also the type of movement you apply might also cause problems. But im not sure what you want exactly,
If you have used a capsul it already has a collider, so you don't need to add another one to it. If you are going to use something like a character controller you want to remove the other colliders (Sphere, capsule, box, whatever) because the character controller already has its own collider. You will keep the rigid body though for things like gravity, and position, or rotation locking,
Camera wise you should get use to not making the main camera part of the character, simply create a new Cam and make it child object of the player and name it Player Camera.
Get use to adding Tag as Player to your Player. But as you see here I have a Camera on the capsule, but it does not have a capsule collider, but rather a character controller that has its own collider. My Player Control script calls for that instead for my movement, but you can use whatever you are trying for,
On my rigid boidy you should also note Use Gravity is checked, and I have the Y on Position, but all three XYZ checked to lock into place. This is because with the scrip I am using I have movement. But locking these positions keeps it from flying off into space if something bumps the character, or i bump into something, etc.
This depends on the script also as this can in some scripts prevent movement altogether, but if bumped will still cause it to drag off slowly to wherever.
So, Make a Player Camera, and it will be the one your player will use, Choose the collider type proper to the movement script you use. Rigid body is what you will be adding to most of what you will be using for characters, enemies and weapon parts.