SyncTestCube.cs
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SyncTestCube : MonoBehaviour {
public float m_MoveSpeed = 2f;
public float m_ScrollSpeed = 30f;
public float m_YawSpeed = 30f;
private Rigidbody m_Rigidbody;
private Material m_ColorMaterial;
private void Awake()
{
m_Rigidbody = GetComponent<Rigidbody>();
m_ColorMaterial = GetComponent<Renderer>().material;
m_ColorMaterial.color = Color.white;
}
// Update is called once per frame
void Update () {
if(GravityBall.Instance.GetButton())
{
m_ColorMaterial.color = Color.red;
}
else
{
m_ColorMaterial.color = Color.white;
}
float xInput = GravityBall.Instance.GetInputAxis("Horizontal");
float zIput = GravityBall.Instance.GetInputAxis("Vertical");
transform.Translate(xInput * m_MoveSpeed * Time.deltaTime, 0, zIput * m_MoveSpeed * Time.deltaTime, Space.World);
float scroll = GravityBall.Instance.GetInputSwipe("Scroll");
float yaw = GravityBall.Instance.GetInputSwipe("Stroke");
transform.Rotate(scroll * m_ScrollSpeed * Time.deltaTime, yaw * m_YawSpeed * Time.deltaTime, 0f,Space.World);
}
}