Развитие гоночек
This commit is contained in:
1 parent
ec60c47652
commit
b54083521f
532 files changed
+16091
-28231
No files matched your search
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
namespace Code.Example.Race.Racer.Car
|
||||
{
|
||||
public class CarWheelRotator : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private NavMeshAgent agent;
|
||||
[SerializeField] private Transform[] wheels;
|
||||
[SerializeField] private bool rotateDebug;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector3 wheelRotation;
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
if (rotateDebug)
|
||||
{
|
||||
UnityEngine.Debug.DrawRay(
|
||||
wheel.position,
|
||||
Vector3.Project(agent.velocity, agent.gameObject.transform.right),
|
||||
Color.yellow, 900f);
|
||||
UnityEngine.Debug.Log(Vector3.Project(agent.velocity, agent.gameObject.transform.right).magnitude);
|
||||
}
|
||||
|
||||
wheelRotation = wheel.localRotation.eulerAngles;
|
||||
wheelRotation.y = Vector3.Project(agent.velocity, agent.gameObject.transform.right).magnitude * 10f;
|
||||
wheel.localRotation = Quaternion.Euler(wheelRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3634956b4d55431b8772a8612e2e3a4d
|
||||
timeCreated: 1769699734
|
||||
@@ -0,0 +1,23 @@
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Racer.Car
|
||||
{
|
||||
public class CarWheelRotatorPlayer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform[] wheels;
|
||||
[SerializeField] private bool rotateDebug;
|
||||
|
||||
public void RotateWheels(float amount)
|
||||
{
|
||||
// UnityEngine.Debug.Log("Rotating Wheels: " + amount);
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
var wheelRotation = wheel.localRotation.eulerAngles;
|
||||
wheelRotation.y = amount;
|
||||
wheel.DOLocalRotate(wheelRotation, 1f);
|
||||
// wheel.localRotation = Quaternion.Euler(wheelRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c90fde90552d48f592b955cbf1ec5c77
|
||||
timeCreated: 1769705011
|
||||
Reference in new issue
Block a user