Question by
BullseyeInformatica · May 02, 2020 at 10:05 AM ·
c#rigidbodycollidertrigger
How to get the Collider other element Rigidbody?
I have a Cube that is a Trigger. And a Sphere with a Rigidboy. I want the Sphere( that has a force applied (1.0f,0.0f,0.0f) ) to move in the Y plane when it enters the Cube.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GoingUp : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
Vector3 movement = new Vector3(0.0f, 5.0f, 0.0f);
other.attachedRigidbody.AddForce(movement);
}
}
But when it applies the vector movement the Sphere doesn't move in the Y plane. What should I do?
Comment