Add camera movement
This commit is contained in:
parent
6a897fabfc
commit
d4a32d9593
3 changed files with 199 additions and 3 deletions
29
Assets/Scripts/CameraMouvement.cs
Normal file
29
Assets/Scripts/CameraMouvement.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class CameraMouvement : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float moveSpeed = 5f;
|
||||
|
||||
private Vector2 _moveInput;
|
||||
public void HandleCameraMovement(InputAction.CallbackContext context)
|
||||
{
|
||||
_moveInput = Vector2.zero;
|
||||
if (context.phase == InputActionPhase.Performed)
|
||||
{
|
||||
_moveInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
}
|
||||
// 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()
|
||||
{
|
||||
var mouvement = moveSpeed * Time.deltaTime * (new Vector3(_moveInput.y, 0, -_moveInput.x));
|
||||
transform.Translate(mouvement, Space.World);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue