https://github.com/kuritaro1122/rotatemanager
[Unity] GameObjectの回転を制御する。回転にかかる速度や時間を自由に制御可能。
https://github.com/kuritaro1122/rotatemanager
csharp unity unity-scripts
Last synced: about 1 month ago
JSON representation
[Unity] GameObjectの回転を制御する。回転にかかる速度や時間を自由に制御可能。
- Host: GitHub
- URL: https://github.com/kuritaro1122/rotatemanager
- Owner: kuritaro1122
- License: mit
- Created: 2021-12-31T04:06:47.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-06T13:14:37.000Z (over 3 years ago)
- Last Synced: 2025-01-07T22:51:42.518Z (over 1 year ago)
- Topics: csharp, unity, unity-scripts
- Language: C#
- Homepage:
- Size: 13.1 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RotateManager
GameObjectの回転を制御する。回転にかかる速度や時間を自由に制御可能。
# Demo
\
[HyperNova](https://kuritaro1122.github.io/HyperNova-Web/)の敵や大砲の回転制御に使っています。
# Requirement
* UnityEngine;
* System;
# Usage
① 任意のGameObjectにRotateManagerをコンポーネント\
② Set関数で目標の回転を設定\
③ StartRotate関数で値を設定して回転開始
```
Transform target;
GameObject self;
RotateManager manager = self.ComponentRotateManager();
manager.Set(target: target, lockPitch: true)
.StartRotate_FixedTime(duration: 1f);
```
# Contains
## Public Function
```
RotateManager Set(Quaternion toRotation) // 静的な回転
RotateManager Set(System.Func toRotation) // 動的な回転
RotateManager Set(Vector3 target, System.Func upwards = null, bool lockPitch = false) // ターゲットを向く(静的な座標)
RotateManager Set(System.Func target, System.Func upwards = null, bool lockPitch = false) // ターゲットを向く(動的な座標)
RotateManager Set(Transform target, System.Func upwards = null, bool lockPitch = false) // ターゲットを向く(Transform)
void StartRotate(float duration, bool speedBase = false, TransitionType transitionType = TransitionType.FixedTimeAndKeep)
void StartRotate_FixedTime(float duration, bool speedBase = false) // 固定時間かけて回転する
void StartRotate_FixedTimeAndKeep(float duration, bool speedBase = false) // 固定時間かけて回転し、ターゲットを向き続ける
void StartRotate_KeepConstansSpeed(float speed) // 一定速度で目標に向けて回転し続ける
bool GetActive()
bool GetFinished()
```
## Extension method
```
RotateManager ComponentRotateManager(this GameObject self)
```
# Note
* StartRotate()のspeedBaseをtrueにすると処理が重くなるため、falseを推奨します。
* ターゲットを向かせる時には、upwardsを設定した方が挙動が安定しやすいです。
# License
"RotateManager" is under [MIT license](https://en.wikipedia.org/wiki/MIT_License).