Question by
StormcloudArts · Sep 02, 2020 at 05:25 AM ·
pinball
Usiing Vector3 to build a pinball table bumper
Hi all, I am trying to build a bumper for my Pinball table in Unity, to bounce the ball away with some force. I have tried using Vector3.forward but this just propells the ball directly up the table, and I want the bumper to simply push the ball away from itself, like in the picture.
Any help would be appreciated :)
here is my code: public class BumperPlateScript : MonoBehaviour { public float power = 100f; List ballList;
void Start()
{
ballList = new List<Rigidbody>();
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Ball"))
{
ballList.Add(other.gameObject.GetComponent<Rigidbody>());
foreach (Rigidbody r in ballList)
{
r.AddForce(power * Vector3.forward);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
how to go about scripting object movement with hingejoint2d 0 Answers
Hinge joint won't work 1 Answer
Pinball Flippers Control with multitouch 0 Answers
2D ball rolling animation 0 Answers