Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 59aabc6

Browse files
committed
add 3d rotation handler example
1 parent a5c55b0 commit 59aabc6

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

‎Assets/Fly.cs‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections;
22
using System.Collections.Generic;
33
using UnityEngine;
4+
using UnityEngine.UIElements;
45

56
public class Fly : MonoBehaviour
67
{
@@ -9,10 +10,24 @@ public class Fly : MonoBehaviour
910

1011
void Update()
1112
{
12-
float translateX = Input.GetAxis("Horizontal") * speed;
13-
float translateY = Input.GetAxis("VerticalY") * speed;
14-
float translateZ = Input.GetAxis("Vertical") * speed;
13+
RotateHandler();
14+
}
15+
16+
public void TranslateHandler()
17+
{
18+
float translateX = Input.GetAxis("Horizontal") * speed;
19+
float translateY = Input.GetAxis("VerticalY") * speed;
20+
float translateZ = Input.GetAxis("Vertical") * speed;
1521

1622
transform.Translate(new Vector3(translateX, translateY, translateZ));
1723
}
24+
25+
public void RotateHandler()
26+
{
27+
float rotationX = Input.GetAxis("Vertical") * speed;
28+
float rotationY = Input.GetAxis("Horizontal") * speed;
29+
float rotationZ = Input.GetAxis("HorizontalZ") * speed;
30+
31+
transform.Rotate(rotationX, rotationY, rotationZ);
32+
}
1833
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /