48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
/*
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* ҡ<EFBFBD>˿<EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Rigidbody
|
|||
|
* <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ҡ<EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
public class RockerControl : MonoBehaviour
|
|||
|
{
|
|||
|
public float moveSpeed = 10f;//<2F>ƶ<EFBFBD><C6B6>ٶ<EFBFBD>
|
|||
|
|
|||
|
private RectTransform MoveJoystick;//ҡ<><D2A1>UI
|
|||
|
private FixedJoystick VarJoy;//ҡ<><D2A1>
|
|||
|
|
|||
|
private Rigidbody rb;//<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// Start is called before the first frame update
|
|||
|
void Start()
|
|||
|
{
|
|||
|
Init();
|
|||
|
}
|
|||
|
|
|||
|
// Update is called once per frame
|
|||
|
void Update()
|
|||
|
{
|
|||
|
Move();
|
|||
|
}
|
|||
|
|
|||
|
void Init()
|
|||
|
{
|
|||
|
rb = transform.GetComponent<Rigidbody>();
|
|||
|
|
|||
|
MoveJoystick = GameObject.Find("MoveJoystick").GetComponent<RectTransform>();
|
|||
|
VarJoy = MoveJoystick.GetComponent<FixedJoystick>();
|
|||
|
}
|
|||
|
|
|||
|
void Move()
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD>ҡ<EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>ƶ<EFBFBD><C6B6>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
Vector3 direction = Vector3.forward * VarJoy.Vertical + Vector3.right * VarJoy.Horizontal;
|
|||
|
//<2F><><EFBFBD><EFBFBD>ֱ<EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>Ŀ<EFBFBD><C4BF>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ƶ<EFBFBD>Ŀ<EFBFBD><C4BF>
|
|||
|
transform.position += direction * moveSpeed * Time.fixedDeltaTime;
|
|||
|
}
|
|||
|
}
|