Question by
Gunthanks · Oct 19, 2017 at 02:11 PM ·
movementscripting beginner
Help me to do this moving player script
I dont know, how I make a simple move Script for one object, I trying this:
// Use this for initialization
void Start () {
animador.SetBool("onFloor",true);
animador.SetBool("moving",false);
animador.SetBool("live", true);
}
// Update is called once per frame
void Update () {
transform.Rotate (Vector3.forward);
animador.SetBool ("onFloor", OnFloor ());
if (OnFloor ()) {
if (Input.GetKeyDown (KeyCode.Space))
jumping ();
}
}
bool OnFloor(){
Colision = Physics2D.Raycast (transform.position,-transform.up,ColisionBox.size.y/2);
if (Colision)
return(true);
else
return(false);
}
void Move(float direction,float velocity){
if (direction > 0)
transform.Rotate (Vector3.forward*0);
if (direction < 0)
transform.Rotate (Vector3.forward+=-180);
rb2D.velocity = new Vector3(rb2D.velocity.x, velocity, rb2D.velocity.x);
if (velocity != 0){
animador.SetBool ("moving", true);
}else {
animador.SetBool ("moving", false);
}
}
void jumping(){
animador.SetBool("onFloor", false);
rb2D.AddForce(transform.up*265);
}
}
Comment