- Home /
My Objects are falling through the floor..
Hi, I'm making a 1:1 running game using unity. but if I start, the player object is falling through the floor. The floor and Player object have their colliders and rigid bodies. And I checked the gravity.. they're not triggers too. Also, the player is not kinematic. I don't know why it happened...
here's my code.
public class Player : NetworkBehaviour {
public Rigidbody rbody;
private float inputH;
private float inputV;
void Start () {
rbody = GetComponent<Rigidbody>();
}
void Update ()
{
if(!isLocalPlayer)
{
return;
}
inputH = Input.GetAxis("Horizontal");
inputV = Input.GetAxis("Vertical");
float moveX = inputH * 500f * Time.deltaTime;
float moveY = 0f;
float moveZ = inputV * 1000f * Time.deltaTime;
rbody.velocity = new Vector3(moveX, moveY, moveZ);
}
}
my english is not really good, so you may can't understand my writing.. if so, tell me. i'll wait for your answer! :)
$$anonymous$$ake sure that your objects are at least a tiny bit above your floor ins$$anonymous$$d of exactly ontop of it, otherwise they might fall through it. If that's not the reason I would try to change rbody.velocity = ... to rbody.AddForce(...)
Asegúrate de no tener el trigger activado puesto que al tener el RigidBody ocasiona que el objeto traspase el suelo.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
How to make player collide with ground? 1 Answer
collider not collidinng with bottom of object 1 Answer
Why object goes sometimes through walls by adding force ? 2 Answers
Problem with rotating a rigidbody 1 Answer