Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
using UnityEngine;
///
/// Контроллер и поведение игрока
///
public class PlayerScript : MonoBehaviour
{
///
/// 1 - скорость движения
///
public Vector2 speed = new Vector2(50, 50);
// 2 - направление движения
private Vector2 movement;
void Update()
{
// 3 - извлечь информацию оси
float inputX = Input.GetAxis("Horizontal");
float inputY = Input.GetAxis("Vertical");
// 4 - движение в каждом направлении
movement = new Vector2(
speed.x * inputX,
speed.y * inputY);
}
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more