Controlling Position
This commit is contained in:
13
Assets/Scripts/MovingSphere.cs
Normal file
13
Assets/Scripts/MovingSphere.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class MovingSphere : MonoBehaviour
|
||||
{
|
||||
private void Update()
|
||||
{
|
||||
Vector2 playerInput;
|
||||
playerInput.x = Input.GetAxis("Horizontal");
|
||||
playerInput.y = Input.GetAxis("Vertical");
|
||||
playerInput = Vector2.ClampMagnitude(playerInput, 1f);
|
||||
transform.localPosition = new Vector3(playerInput.x, 0.5f, playerInput.y);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user