Hi,
what a refreshingly busy site!
I’m a new unity user working my way through one tutorial after the other.
In my experimental unity scene i have a sphere that’s supposed to be bouncing between two caps infinitely (see picture). The sphere’s speed is adjustable in the editor (default: 1) by a public speed-variable in the controlling script. As I increase speed to a value of round 3 or 4 the sphere still bounces in between the caps a couple of times (how many time differs everytime) and then stops on collision with one of the caps, velocity being 0 at this point.
code:
public var speed : float;
function Start(){
speed = 1;
rigidbody.velocity.y = speed;
}
function Update () {
Debug.Log(rigidbody.velocity.y);
}
function OnCollisionEnter(collision : Collision) {
Debug.Log(rigidbody.velocity.y);
if(rigidbody.velocity.y > 0){
rigidbody.velocity.y = -speed;
}else{
rigidbody.velocity.y = speed;
}
}
What is it that I’m not considering?
scene: