Hello, well like the title says, I’m making a simple game, and I want to stop the momentum of a ball.
When I make the input to move the ball simply goes forward, and when it respawns the momentum stays in a loop, like “Portal” game, I did a research of how to do it and didn’t find anything useful
Here’s my code (C#):
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour
{
public float speed;
private Vector3 spawn;
void Start()
{
spawn = transform.position;
}
void FixedUpdate()
{
float moveHor = Input.GetAxis ("Horizontal");
float moveVert = Input.GetAxis ("Vertical");
Vector3 move = new Vector3 (moveHor,0.0f, moveVert);
rigidbody.AddForce (move * speed * Time.deltaTime);
if(transform.position.y <= -4)
{
transform.position = spawn;
}
}
}
I did try the code
rigidbody.velocity = Vector3.zero;
rigidbody.AddForce = Vector3.zero;
rigidbody.angularDrag = Vector3.zero;
I did try making more variables, and same results
It didn’t work
Thanks for reading