- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38268
- 精华
- 111
|
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// My First Script
- /// </summary>
- public class ControlScript : MonoBehaviour
- {
- public GameObject Player = null;
- void Awake()
- {
- }
- void Start()
- {
- if (Player == null)
- {
- _HasPlayer = false;
- }
- }
- void Update()
- {
- if (_HasPlayer && Player.activeInHierarchy)
- {
- float h = Input.GetAxis("Horizontal");
- float v = Input.GetAxis("Vertical");
- Player.transform.Translate(0, 0, _Speed * v);
- Player.transform.Rotate(0, _Speed * h, 0);
- }
- if (Input.GetKeyDown(KeyCode.J))
- {
- ++_Speed;
- }
- if (Input.GetKeyDown(KeyCode.M))
- {
- --_Speed;
- if (_Speed < 1f)
- {
- _Speed = 1f;
- }
- }
- }
- void LateUpdate()
- {
- }
- bool _HasPlayer = true;
- float _Speed = 1.0f;
- }
复制代码 |
|