// Update is called once per frame void Update() { Vector3 dir = Vector3.zero; dir.y = Rig.velocity.y; dir.x = Joystick.Horizontal(); if (dir.x != 0) { float dire = 1; if (dir.x > 0) { direction = true; dir.x = moveSpeed; } else if (dir.x < 0) { direction = false; dir.x = moveSpeed * -1; } } //dir.y = Joystick.Vertical (); if (dir.x > 0) { direction = true; } else if (dir.x < 0) { direction = false; } if (dir.y < -5) { dir = new Vector2(dir.x, -10); } if (jump) { GetComponent <AudioSource> ().PlayOneShot(Aud); if (Rig.gravityScale > 0) { Rig.AddForce(new Vector2(0, jumpspeed)); } else { Rig.AddForce(new Vector2(0, jumpspeed * -1)); } //dir = new Vector2 (dir.x, jumpspeed); grounded = false; jump = false; } aaa = dir; Rig.velocity = dir; }
private Vector3 PoolInput() { Vector3 dir = Vector3.zero; dir.x = Joystick.Horizontal(); dir.y = Joystick.Vertical(); if (dir.magnitude > 1) { dir.Normalize(); } return(dir); }
private Vector3 PoolInput() { Vector3 dir = Vector3.zero; dir.x = Joystick.Horizontal(); if (dir.magnitude > 1) { dir.Normalize(); } if (dir.x > 0) { Plat.direction = true; } else if (dir.x < 0) { Plat.direction = false; } dir = new Vector2(dir.x, Plat.aaa.y); return(dir); }