How do I make a ball have force where it bounces and adds force in the direction it is going at?
Here is my current script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Blah : MonoBehaviour {
public float jumpSpeed;
private bool ifTrue;
// Use this for initialization
void Start () {
ifTrue = true;
}
// Update is called once per frame
void Update () {
if(ifTrue == true)
{
GetComponent<Rigidbody2D>().AddForce(transform.up * jumpSpeed);
}
}
}
I can't find out how to make it go the direction it bounces off of (using bouncy material) and add force that way and not up. (I have very little experience coding)
Comment