feat: polish VR gameplay and sync tools
This commit is contained in:
@@ -13,24 +13,42 @@ namespace VRBeats
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (colorSide == ColorSide.Left) controller = VR_Manager.instance.Player.LeftController;
|
||||
if (colorSide == ColorSide.Right) controller = VR_Manager.instance.Player.RightController;
|
||||
ResolveController();
|
||||
}
|
||||
|
||||
protected override DamageInfo CreateDamageInfo(Vector3 hitPoint)
|
||||
{
|
||||
ResolveController();
|
||||
|
||||
var damageInfo = base.CreateDamageInfo(hitPoint);
|
||||
BeatDamageInfo beatDamageInfo = new BeatDamageInfo(damageInfo);
|
||||
|
||||
Vector3 controllerVelocity = controller.Velocity;
|
||||
Vector3 controllerVelocity = controller != null ? controller.Velocity : Vector3.zero;
|
||||
|
||||
beatDamageInfo.hitForce = Mathf.Min((controllerVelocity * hitForce).magnitude, maxHitForce);
|
||||
beatDamageInfo.hitObject = gameObject;
|
||||
beatDamageInfo.colorSide = colorSide;
|
||||
beatDamageInfo.velocity = controller.Velocity.magnitude;
|
||||
beatDamageInfo.velocity = controllerVelocity.magnitude;
|
||||
|
||||
return beatDamageInfo;
|
||||
}
|
||||
|
||||
private void ResolveController()
|
||||
{
|
||||
VR_Grabbable grabbable = GetComponent<VR_Grabbable>();
|
||||
if (grabbable != null && grabbable.GrabController != null)
|
||||
{
|
||||
controller = grabbable.GrabController;
|
||||
colorSide = controller.ControllerType == VR_ControllerType.Right ? ColorSide.Right : ColorSide.Left;
|
||||
return;
|
||||
}
|
||||
|
||||
if (VR_Manager.instance == null || VR_Manager.instance.Player == null)
|
||||
return;
|
||||
|
||||
controller = colorSide == ColorSide.Left
|
||||
? VR_Manager.instance.Player.LeftController
|
||||
: VR_Manager.instance.Player.RightController;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user