How To Stop Constant Movement of RB Force
So, I'm in the process of making a pinball type game, but the plunger, or spring (or thing that makes ball go), keeps moving after running through a teleportTarget trigger. Make long story short, I need to find a way to either create a force to stop the constant moving of the plunger, or create a negative force to stop it in its tracks (Plunger Script and trigger script below)
Plunger using System.Collections; using System.Collections.Generic; using UnityEngine;
public class SpringScript : MonoBehaviour { public float springPush = 5000f; public Rigidbody rb;
void FixedUpdate()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(0, 0, springPush * Time.deltaTime);
}
}
**//the problem area**
void OnCollisionEnter (Collision collsiionInfo)
{
if (collsiionInfo.collider.tag == "SpringTrigger")
{
}
}
}
Trigger using System.Collections; using System.Collections.Generic; using UnityEngine;
public class SpringReset : MonoBehaviour { public Transform teleportTarget; public GameObject spring;
void OnTriggerEnter(Collider other)
{
spring.transform.position = teleportTarget.transform.position;
}
}
Your answer
Follow this Question
Related Questions
Enable/Disable MeshRenderer on trigger enter/exit 0 Answers
Problems with respawning using a very simple script 1 Answer
How do i ajust the player height acording to the height of the roof in a first person game? 1 Answer
OnTriggerEnter2D problem 1 Answer
How to use value from a function in another function 1 Answer