I am trying to create a boost pad that when the player enters they will be launched into the air. I have created the basic effect of launching the player into the air, but I also want to have it so when the players is launched, they are also launched forward in the direction of another platform without the player having to guide themselves to the other platform.
Here is my code right now.
using UnityEngine;
using System.Collections;
public class Boost_pad : MonoBehaviour {
public float velocity = 10.0f;
public float force = 20.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider c)
{
if (c.tag == "Player")
{
c.rigidbody.velocity = Vector3.up * velocity;
}
}
void OnTriggerExit(Collider c)
{
if (c.tag == "Player")
{
c.rigidbody.AddForce(Vector3.forward * force, ForceMode.Acceleration);
}
}
}