Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Created June 24, 2022 12:26
Show Gist options
  • Save pr00thmatic/09a98605a024892c88d68f96d133f304 to your computer and use it in GitHub Desktop.
Save pr00thmatic/09a98605a024892c88d68f96d133f304 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MovimientoDelHeroe : MonoBehaviour {
[Header("Initialization")]
public Camera cam;
[Header("Information")]
public float speed = 30; // m/s
void Reset () {
cam = Camera.main;
}
void Update () {
Vector3 right = cam.transform.right;
Vector3 forward = cam.transform.forward;
right.y = forward.y = 0;
transform.position +=
( right * Input.GetAxis("Horizontal") +
forward * Input.GetAxis("Vertical")) * speed * Time.deltaTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment