I have created a simple script which will move the sphere in a projectile motion.
public class ProjectileTest : MonoBehaviour
{
public float power;
public float speed = 1f;
void OnGUI ()
{
if(GUI.Button(new Rect(100, 100, 100, 50), "Reset"))
{
Application.LoadLevel(Application.loadedLevel);
}
}
void Update ()
{
if (Input.GetMouseButtonDown (0))
{
}
if (Input.GetMouseButton (0))
{
power+=0.1f;
}
if (Input.GetMouseButtonUp (0))
{
Debug.Log("Power : "+power);
if(power > 10)
power = 10f;
transform.rigidbody.isKinematic = false;
Vector3 forceVector = new Vector3(1, 1, 0);
transform.rigidbody.velocity = forceVector * power * speed;
}
}
}
Now as the question says, how can i control the speed of the projectile motion?
The sphere should move in the projectile but with a factor of speed.
Like sometimes i want it to move fast or slow but the projectile path should be same.