Hey Unity Answers Users…
I’m here today with a script and a problem. I need to find a way to add force to a projectile fired at another object. I need it to be in a curve fashion (Catapult Effect).
Here is my script:
#pragma strict
var sProjSpd : int;
var sProjDir : Vector3;
var targetP : GameObject;
function OnEnable()
{
targetP = GameObject.FindGameObjectWithTag("targetP");
sProjDir = Vector3.Normalize(this.transform.position);
}
function Update()
{
if(Input.GetKeyDown(“space”))
{
transform.position = Vector3.MoveTowards(this.transform.position, targetP.transform.position, sProjSpd*Time.deltaTime);
}
}
Any help would be great. I have dabbled in putting addforce and forcemode.impulse but they seem not to work.
Regards,
Trent