- Home /
Script error: No appropriate version of 'UnityEngine.Transform.TransformDirection' for the argument list '(System.Type)' was found
var speed = 3.0;
var rotateSpeed = 3.0;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3);forward;
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
}
@script RequireComponent(CharacterController)
when i try to run this script it tells me an error: Assets/MoveAroundObjectScript.js(7,43): BCE0023: No appropriate version of 'UnityEngine.Transform.TransformDirection' for the argument list '(System.Type)' was found.
When posting code in your question, please highlight it and press the 'format code' icon (with 0s and 1s). $$anonymous$$akes it much easier to read! ;)
Answer by · Oct 07, 2010 at 07:57 AM
The problem is with this:
var forward = transform.TransformDirection(Vector3);forward
I think you meant to type:
var forward = transform.TransformDirection(Vector3.forward);
The script reference for TransformDirection explains the correct syntax, and gives examples.
However, if I correctly understand what you're trying to do, you can just use transform.forward, which is the blue/z/forward axis of the transform in world space.
Answer by Mike 12 · Dec 08, 2010 at 05:37 PM
Actually, you can use both Vector3.forward and transform.forward, as I've seen both used before. The end result, however, appears to be different from each other so they're not exactly interchangeable.
The point was, transform.forward is interchagable with transform.TransformDirection(Vector3.forward)
Your answer
Follow this Question
Related Questions
sound on button press error + its firing when space is pressed 1 Answer
Broken Script Help 1 Answer
How "include" the Raycast?! 1 Answer