Аудио
- 1 ответ
- 0 вопросов
0
Вклад в тег
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BroomController : MonoBehaviour
{
private GameObject broom;
private bool InHand = true;
void Start()
{
broom = GameObject.Find("Broom");
Cursor.visible = false;
}
void Update()
{
GameObject parent = broom.transform.parent.gameObject;
float targetAngle = 0f;
if (Input.GetKey("q") || Input.GetKey("e"))
{
if (Input.GetKey("q"))
{
targetAngle = 20f;
}
if (Input.GetKey("e"))
{
targetAngle = -20f;
}
Quaternion parentRotation = parent.transform.rotation;
Quaternion targetRotation = Quaternion.Euler(0, 0, targetAngle);
Quaternion broomTargetRotation = parentRotation * targetRotation;
broom.transform.rotation = Quaternion.RotateTowards( broom.transform.rotation, broomTargetRotation, Time.deltaTime * 180f);
}
}
}