I’m having an issue where the OVR Skeleton Physics Capsules are moving when they collide with a Box Collider trigger. Here’s a video demonstrating this;
The all stop touchscreen button ‘STP’ resets the velocity applied to the main ship’s rigidbody with Vector3.zero, weird that it’s resetting the OVR skeleton as well. I do have the OVR Camera Rig as a child to the main gameobject that I applied the rigidbody too…
Here’s the code I hobbled together for touchscreen buttons. I have it so the actual box collider trigger on the button moves away from the actual button for 1 second then returns - I did this OnTriggerEnter was firing to many times, and I’m a novice when it comes to Unity and C#, I’m sure there is a better way;
public class ButtonTrigger : MonoBehaviour
{
[SerializeField]
private Sprite pressedSprite;
[SerializeField]
private Sprite resetSprite;
private BoxCollider bC;
[SerializeField]
private SpriteRenderer sR;
[SerializeField]
private UnityEvent onButtonPressed;
private Vector3 resetPos = new Vector3(0, 0, 0);
private Vector3 pushPos = new Vector3(0,0,-0.05f);
public float timer = 0.0f;
public bool isPushed = false;
void Start()
{
bC = GetComponent<BoxCollider>();
}
private void Update()
{
if (isPushed == true)
{
timer += Time.deltaTime;
if (timer >= 1f)
{
bC.transform.localPosition = resetPos;
isPushed = false;
timer = 0f;
sR.sprite = resetSprite;
}
}
}
private void OnTriggerEnter(Collider other)
{
onButtonPressed?.Invoke();
sR.sprite = pressedSprite;
bC.transform.localPosition = pushPos;
isPushed = true;
}
}
I’d appreciate any suggestions. Oh and this project is just for myself, something to keep me motivated while learning blender, unity and C# - I know how much CBS likes to ruin the fun for Star Trek fans