mirror of
https://github.com/PorktoberRevolution/ReStocked
synced 2024-09-01 17:34:42 +00:00
Update project organization and fix constraint but
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Restock.Constraints
|
||||
@ -21,15 +22,21 @@ namespace Restock.Constraints
|
||||
node.TryGetValue("targetName", ref targetName);
|
||||
|
||||
rotator = p.FindModelTransform(rotatorsName);
|
||||
if (rotator == null)
|
||||
{
|
||||
throw new Exception($"Missing rotator transform {rotator}");
|
||||
}
|
||||
target = p.FindModelTransform(targetName);
|
||||
if (target == null)
|
||||
{
|
||||
throw new Exception($"Missing target transform {target}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (rotator == null || target == null) return;
|
||||
|
||||
var lookPos = target.position - rotator.position;
|
||||
var rotation = Quaternion.LookRotation(lookPos, target.up);
|
||||
var rotation = Quaternion.LookRotation(lookPos, rotator.up);
|
||||
rotator.rotation = rotation;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user