- Home /
how can i change movments??
hi there..i been working on a pong game, i already have a code for the ball to move but i need it to make it different..so here is what ive got:
#pragma strict
//velocity....
var cSpeed:float=10.0;
//movement factor...
var cFactor:float = 10.0;
//score
static var scorePlayer=0;
static var scoreEnemy=0;
function Start () {
rigidbody.AddForce(Vector3(500,0,0));
}
function Update () {
var cve1 =rigidbody.velocity;
var tve1 = cve1.normalized*cSpeed;
rigidbody.velocity= Vector3.Lerp(cve1, tve1, Time.deltaTime*cFactor);
if(transform.position.x>30)
{
scorePlayer++;
transform.position.x=0;
transform.position.y=0;
}
if(transform.position.x<-30)
{
scoreEnemy++;
transform.position.x=0;
transform.position.y=0;
}
}
any idea??? please!
Comment
So what was your problem and what are you doing on that script?
Your answer
Follow this Question
Related Questions
How to move a object side to side using mouse? js3 0 Answers
How to freeze movement on X-axis. (See Comments for Update) 2 Answers
Master Server and Faciliator connection 0 Answers
Unity pong online multiplayer 0 Answers
End a game? 2 Answers