1234567891011121314151617181920212223242526272829 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MyCharacterController : MonoBehaviour
- {
- //½ÇÉ«¿ØÖÆÆ÷
- private CharacterController cc;
- //ËÙ¶È
- public float speed = 10;
- // Start is called before the first frame update
- void Start()
- {
- cc = GetComponent<CharacterController>();
- }
- // Update is called once per frame
- void Update()
- {
- float x = Input.GetAxis("Horizontal");
- float y = Input.GetAxis("Vertical");
- if (x != 0 || y != 0)
- {
- cc.SimpleMove(new Vector3(x, 0, y) * speed);
- }
- }
- }
|