Game Development Community

t2dVectorNormalise

by praju · in Torque Game Builder · 07/24/2010 (6:55 am) · 7 replies

Hi,

I am giving t2dvectorNormalise(%direction) in my script file. But it is shown in the console -"Invalid number of parameters for t2dvectorNormalise() ". What is going wrong??? :(

#1
07/24/2010 (5:45 pm)
It only gives that error if you pass in a string with only one number:

t2dVectorNormalize( "5" ); // Error

t2dVectorNormalize( "5 0" ); // Returns "1 0"
#2
07/24/2010 (9:15 pm)
What value do you assign to the %direction ?
#3
07/24/2010 (10:02 pm)
You can assign any vector.

For example, you might normalize the velocity and then scale it by, say, 10 to see where the player would be if the velocity didn't change.
#4
07/26/2010 (5:19 am)
Actually, i think its the problem with my logic.

Lets say there is one ball and a player. The player faces the ball and moves towards it and kicks it. Now the problem is that, i am not getting to move the ball in the right direction as the player. What do you think guys???
#5
07/26/2010 (6:13 am)
What do we do to get acceleration???

When i do %direction * %force / %mass, the TGB is not calculating..!
here %direction is a vector.

#6
07/26/2010 (7:53 pm)
Maybe try using:

%scaledDirection = t2dVectorScale( %direction, %force / %mass );

I am assuming that your %direction vector is already normalised?
Try to output your variables to the console, by calling echo( %direction );
#7
07/27/2010 (4:08 am)
Thank you Piotr!!!! Got it !!

working fine now. It was the problem with not using t2dvectorScale. Never knew that function existed...:P