Quantcast
Channel: Answers by "ThePersister"
Viewing all articles
Browse latest Browse all 99

Answer by ThePersister

$
0
0
Hi there friendly @Gotal. Based on your code. Perhaps this helps? If it does, please accept my answer! :) Otherwise, elaborate and I could try again. using UnityEngine; using System.Collections; public class ObjectStopper : MonoBehaviour { public myObject targetObject; // not my real objects name public float stopSpeed = 10f; private bool isStopping; void Update() { if ( isStopping ) { // Mathf.Max => Prevents negative speed. targetObject.speedObject = Mathf.Max(0f, targetObject.speedObject - stopSpeed * Time.deltaTime); } } void OnTriggerEnter( Collider col ) { if( col.tag == "frontOfObject" ) { Debug.Log( "Stop me over time Senpai!" ); isStopping = true; } } }

Viewing all articles
Browse latest Browse all 99

Trending Articles