mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
testing
This commit is contained in:
parent
24482174f1
commit
d735e65032
@ -1,6 +1,7 @@
|
|||||||
using NewHorizons.Utility.OuterWilds;
|
using NewHorizons.Utility.OuterWilds;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
namespace NewHorizons.Components;
|
namespace NewHorizons.Components;
|
||||||
|
|
||||||
@ -19,11 +20,16 @@ public class AddPhysics : MonoBehaviour
|
|||||||
"If there's already good colliders on the detail, you can make this 0.")]
|
"If there's already good colliders on the detail, you can make this 0.")]
|
||||||
public float Radius = 1f;
|
public float Radius = 1f;
|
||||||
|
|
||||||
|
private OWRigidbody parentBody;
|
||||||
|
private OWRigidbody owRigidbody;
|
||||||
|
|
||||||
private IEnumerator Start()
|
private IEnumerator Start()
|
||||||
{
|
{
|
||||||
yield return new WaitForSeconds(.1f);
|
yield return new WaitForSeconds(.1f);
|
||||||
|
|
||||||
var parentBody = GetComponentInParent<OWRigidbody>();
|
parentBody = GetComponentInParent<OWRigidbody>();
|
||||||
|
|
||||||
|
// yield return new WaitUntil(() => Keyboard.current.lKey.isPressed);
|
||||||
|
|
||||||
// hack: make all mesh colliders convex
|
// hack: make all mesh colliders convex
|
||||||
// triggers are already convex
|
// triggers are already convex
|
||||||
@ -37,8 +43,10 @@ public class AddPhysics : MonoBehaviour
|
|||||||
bodyGo.transform.position = transform.position;
|
bodyGo.transform.position = transform.position;
|
||||||
bodyGo.transform.rotation = transform.rotation;
|
bodyGo.transform.rotation = transform.rotation;
|
||||||
|
|
||||||
var owRigidbody = bodyGo.AddComponent<OWRigidbody>();
|
owRigidbody = bodyGo.AddComponent<OWRigidbody>();
|
||||||
owRigidbody._simulateInSector = Sector;
|
owRigidbody._simulateInSector = Sector;
|
||||||
|
// owRigidbody._autoGenerateCenterOfMass = false;
|
||||||
|
// owRigidbody._centerOfMass = owRigidbody.transform.InverseTransformPoint(parentBody.GetPosition());
|
||||||
|
|
||||||
bodyGo.layer = Layer.PhysicalDetector;
|
bodyGo.layer = Layer.PhysicalDetector;
|
||||||
bodyGo.tag = "DynamicPropDetector";
|
bodyGo.tag = "DynamicPropDetector";
|
||||||
@ -72,8 +80,7 @@ public class AddPhysics : MonoBehaviour
|
|||||||
|
|
||||||
transform.parent = bodyGo.transform;
|
transform.parent = bodyGo.transform;
|
||||||
owRigidbody.SetMass(Mass);
|
owRigidbody.SetMass(Mass);
|
||||||
owRigidbody.SetVelocity(parentBody.GetPointVelocity(transform.position));
|
owRigidbody.SetVelocity(parentBody.GetPointVelocity(owRigidbody.GetWorldCenterOfMass()));
|
||||||
owRigidbody.SetAngularVelocity(parentBody.GetAngularVelocity());
|
|
||||||
|
|
||||||
// #536 - Physics objects in bramble dimensions not disabled on load
|
// #536 - Physics objects in bramble dimensions not disabled on load
|
||||||
// sectors wait 3 frames and then call OnSectorOccupantsUpdated
|
// sectors wait 3 frames and then call OnSectorOccupantsUpdated
|
||||||
@ -82,6 +89,8 @@ public class AddPhysics : MonoBehaviour
|
|||||||
if (owRigidbody._simulateInSector != null)
|
if (owRigidbody._simulateInSector != null)
|
||||||
owRigidbody.OnSectorOccupantsUpdated();
|
owRigidbody.OnSectorOccupantsUpdated();
|
||||||
|
|
||||||
|
yield return new WaitUntil(() => Keyboard.current.kKey.isPressed);
|
||||||
|
|
||||||
Destroy(this);
|
Destroy(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,4 +98,16 @@ public class AddPhysics : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Gizmos.DrawWireSphere(transform.position, Radius);
|
Gizmos.DrawWireSphere(transform.position, Radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRenderObject()
|
||||||
|
{
|
||||||
|
Popcron.Gizmos.Sphere(transform.position, Radius);
|
||||||
|
Popcron.Gizmos.Line(transform.position, parentBody.GetPosition());
|
||||||
|
Popcron.Gizmos.Line(transform.position, owRigidbody.GetWorldCenterOfMass());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
// owRigidbody.SetVelocity(parentBody.GetPointVelocity(owRigidbody.GetWorldCenterOfMass()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user