Hey, another quick question here from a beginner. II'm playing around with code and right now I'm trying to figure out how to create a bouncing ball without using any physics/force/gravity. I'm basically trying to learn how this kinda coding works so I can apply it to other things that aren't exactly meant to be physics based.. here it is so far(not very far :)):
var YMovement : float = 0;
var damp:float;
var fall:float;
var jump:boolean=false;
function Update ()
{
if(jump==false){
YMovement = Mathf.Lerp(YMovement, -1, Time.deltaTime*damp);
transform.Translate (0,YMovement * 12 * Time.deltaTime, 0);
}else if(jump==true){
transform.position.y+=fall*Time.deltaTime; //???
}
}
function OnTriggerEnter(col:Collider){
if(col.gameObject.tag=="ground"){
jump=true;
}
}
this code is attached to a box that would be bouncing on top of another box tagged as "ground". Right now after the bounce all I have is the ball shooting towards the positive y axis, but the initial fall is the way I want it ..Any pointer on how to do this or if I'm even doing it right would be greatly appreciated.