- Home /
Sphere falling through floor
I made a little setup by following the tornadotwins tutorial on youtube with a sphere and i cant get it to work. The sphere keeps falling through the floor. This is my script i have applied to my sphere.
var speed = 3.0; var rotateSpeed = 3.0;
function Update () { var controller : CharacterController = GetComponent(CharacterController);
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
// Move forward / backward
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
}
@script RequireComponent(CharacterController)
Is it always falling through the floor, or only sometimes? Quick things to try: Is it starting out already inside the floor (click on it and look at the green collision capsule. Is it under the floor?) Try raising it a little off the floor so it falls before hitting.
If that doesn't work, then try removing the character controller and replacing it with a rigidbody. Add a sphere collider to it. Now see if that collides with the floor. (Remember to disable your script or you'll get an error about when you try to access the CharacterController). If that still doesn't collide then look at your Time settings. Fixed timestep should be something like 0.02 or 0.01. Last check your Settings->Physics->Layer Collision $$anonymous$$atrix. $$anonymous$$ake sure the two layers of your sphere and ground are enabled to collide
@UnityNoOb18 I solved the issue by making a brand new project that is not based on an existing project, such as Boot Camp Demo
One thing I have discovered is that applying the controls to the ball itself makes the rotation of the object change the direction of the input.
For example: roll onto the left side, and now your left input control is facing down, through the floor. Hitting the ball "left" therefor works to push the ball through the floor plane.
Answer by DaveA · Jun 06, 2011 at 01:01 AM
You did put a collider on the floor, right? And nothing is set to 'is trigger'?
Answer by UnityNoOb18 · Jun 06, 2011 at 01:21 AM
the floor is a cube and it has a box collider and mesh renderer the sphere has a mesh renderer character controller the script attatched to it a sphere collider and a rigidbody.
Answer by reapex · Jun 06, 2011 at 01:29 AM
I am having the same issue, with Unity 3.3, the floor is has a box collider and a rigid body. The sphere has a sphere collider and the following script:
var speed = 3.0; var rotateSpeed = 3.0; function Update () { var controller : CharacterController = GetComponent(CharacterController); transform.Rotate(0, Input.GetAxis ("Horizontal") rotateSpeed, 0); var forward = transform.TransformDirection(Vector3.forward); var curSpeed = speed Input.GetAxis ("Vertical"); controller.SimpleMove(forward * curSpeed); } @script RequireComponent(CharacterController)
The ball still falls through the floor.
Answer by raymond.du · Jun 06, 2011 at 03:22 AM
it's moving too fast. The collider missed by a frame. http://www.unifycommunity.com/wiki/index.php?title=DontGoThroughThings
Your answer
Follow this Question
Related Questions
Variable Script "movement" 2 Answers
Airplane Script Control 1 Answer
funky rigidbody movement 0 Answers
The referenced script on this behavior is missing! 2 Answers