I am trying to make a simple pinball game. For the trigger that launches the ball I want to have that activated by the space bar. When I hit space with the script below sometimes the ball goes all the way up like I want, other times it goes halfway and other times it glitches through my Blender model and falls into space. I don’t know if it is the code or if it is in Unity itself. I have tried the “Don’t Go Through Things” script already and that did not help.
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour
{
public float speed = 5f;
public float upspeed = 5f;
void FixedUpdate ()
{
if(Input.GetKeyUp(KeyCode.Space))
transform.position += new Vector3(speed * Time.deltaTime, upspeed * Time.deltaTime, 0.0f);
rigidbody.AddForce (transform.position);
}
}