- Home /
Melee system script help
#pragma strict
var Damage : int = 25;
var Distance : float;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward, hit))
)
{Distance = hit.distance;
hit.transform.SendMessage("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver);
}
}
;
This is a script for a melee system but i keep getting an error message saying "Assets/Themeleesystem.js(11,70): BCE0023: No appropriate version of 'UnityEngine.Transform.TransformDirection' for the argument list '(UnityEngine.Vector3, UnityEngine.RaycastHit)' was found."
How can this be fixed. Any help will be appreciated if it matters its unity 3D
Answer by aldonaletto · Jul 03, 2013 at 03:18 PM
There's a misplaced right parenthesis:
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward, hit))
)
The first right parenthesis should be after Vector3.forward, like this:
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
But you could simplify this statement as follows:
if (Physics.Raycast (transform.position, transform.forward, hit))
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Game Scripts http://pastebin.com/wzN7N5qK 1 Answer
Shooting at ground 1 Answer
Unity and Ports : Networking 1 Answer
Player Attack malfunction 1 Answer