viewing paste Unknown #14548 | C#

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
using UnityEngine;
 
public class PlayerScript : MonoBehaviour
{
  public Vector2 speed = new Vector2(50, 50);
  private Vector2 movement;
 
  void Update()
  {
    float inputX = Input.GetAxis("Horizontal");
    float inputY = Input.GetAxis("Vertical");
 
    movement = new Vector2(
      speed.x * inputX,
      speed.y * inputY);
 
  }
 
  void FixedUpdate()
  {
    rigidbody2D.velocity = movement;
  }
}
 
Viewed 330 times, submitted by Pyrly.