Improve player movement and add collision

This commit is contained in:
2024-10-19 14:58:16 -07:00
parent 3094a3eca6
commit d089d9bfb2
4 changed files with 54 additions and 26 deletions

View File

@@ -6,16 +6,15 @@ public class Teo : MonoBehaviour
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(
Input.GetAxis("Horizontal")*moveSpeed*Time.deltaTime,
Input.GetAxis("Vertical")*moveSpeed*Time.deltaTime,
0
);
Rigidbody2D controller = GetComponent<Rigidbody2D>();
controller.linearVelocity = new Vector2 (
Input.GetAxis("Horizontal"),
Input.GetAxis("Vertical")
).normalized * moveSpeed;
}
}