Created
November 8, 2021 11:22
-
-
Save onlyoneaman/ac26fe1f059986976d4cb94219e312bb to your computer and use it in GitHub Desktop.
Roll Ball Player Extension Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.InputSystem; | |
public class PlayerController : MonoBehaviour | |
{ | |
public float speed = 0; | |
private Rigidbody rb; | |
private float movementX; | |
private float movementY; | |
void Start() | |
{ | |
rb = GetComponent<Rigidbody>(); | |
} | |
void OnMove(InputValue movementValue) | |
{ | |
Vector2 movementVector = movementValue.Get<Vector2>(); | |
movementX = movementVector.x; | |
movementY = movementVector.y; | |
} | |
void FixedUpdate() | |
{ | |
Vector3 movement = new Vector3(movementX, 0.0f, movementY); | |
rb.AddForce(movement * speed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment