Demo entry 6632326

1

   

Submitted by anonymous on Jul 25, 2017 at 03:30
Language: C#. Code size: 775 Bytes.

01.using System.Collections;  
02.using System.Collections.Generic;  
03.using UnityEngine;  
04.  
05.[RequireComponent(typeof(PlayerController))]  
06.  
07.public class Player : MonoBehaviour {  
08.  
09.    public float moveSpeed = 5;  
10.    PlayerController controller;  
11.  
12.    // Use this for initialization  
13.    void Start () {  
14.        controller = GetComponent<PlayerController>();  
15.    }  
16.      
17.    // Update is called once per frame  
18.    void Update ()  
19.    {  
20.        Vector3 moveInput = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));  
21.        Vector3 moveVelocity = moveInput.normalized * moveSpeed;  
22.        controller.Move(moveVelocity);  
23.    }  
24.}  
 

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).