Player movement experiments

This commit is contained in:
2022-04-24 12:03:22 +02:00
parent 9c85dfa48f
commit 42d5679afb
3 changed files with 99 additions and 71 deletions

View File

@@ -26,14 +26,37 @@ public class Player : MonoBehaviour
public void OnMove(InputValue value)
{
Vector2 inputVector = value.Get<Vector2>();
direction = inputVector.x;
direction = inputVector.x;
// 90 deg directional movement
return;
float directionY = inputVector.y;
if (direction >0) {
transform.rotation = Quaternion.Euler(0, 90, 0);
}
else if (direction < 0)
{
transform.rotation = Quaternion.Euler(0, -90, 0);
}
if (directionY > 0)
{
transform.rotation = Quaternion.Euler(0, 0, 0);
}
else if (directionY < 0)
{
transform.rotation = Quaternion.Euler(0, 180, 0);
}
}
// Update is called once per frame
void Update()
{
// Mouse direction movement
//Vector3 mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Mouse.current.position.ReadValue().x, Mouse.current.position.ReadValue().y, Camera.main.transform.position.z - transform.position.z));
//mousePos.y = transform.position.y;
//transform.LookAt(mousePos);
//if isLit decrease health
if (isLit)
@@ -57,6 +80,7 @@ public class Player : MonoBehaviour
transform.position += transform.forward * speed * Time.deltaTime;
//rotate based on direction
transform.Rotate(0, direction * rotationSpeed * 2 * Time.deltaTime, 0);