x


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.

more ▼

asked Oct 07 '10 at 07:37 AM

domagoj gravatar image

domagoj
1 1 1 1

When posting code in your question, please highlight it and press the 'format code' icon (with 0s and 1s). Makes it much easier to read! ;)

Oct 07 '10 at 08:05 AM Marowi
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Oct 07 '10 at 07:57 AM

Marowi gravatar image

Marowi
4.9k 4 14 53

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Dec 08 '10 at 05:37 PM

Mike 12 gravatar image

Mike 12
136 6 7 9

The point was, transform.forward is interchagable with transform.TransformDirection(Vector3.forward)

Dec 08 '10 at 06:31 PM Mike 3
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1951
x198
x41

asked: Oct 07 '10 at 07:37 AM

Seen: 1450 times

Last Updated: Nov 10 '10 at 02:46 AM