SetConstantForce() parameters x/y
by Dawid Zwiewka · in Torque Game Builder · 11/09/2009 (12:15 pm) · 5 replies
Hi!
I know I can call SetConstantForce function like that:
Should I convert my variables to vector? I read something about getWord() but I think that I didn't understand it entirely :)
And second question:
How does gravitic work? If I have constantForce == "10 0" it means that LinearVelocityX of that object will increase by 10 every second? And 10 is...? Pixels? Maybe it refer to Camera Size?
If I change the resolution in my game from 640x480 to 1024x768 and leave constant force same object will increase its speed slower?
I know I can call SetConstantForce function like that:
SetConstantForce("50 50", true);but what if I have constant force which I want to change in 2 variables? For example:%ConstForceX = getRandom(10,50); %ConstForceY = getRandom(10,50); %obj.SetConstantForce(%ConstForceX, %ConstForceY, true); //I think that will not work.I think that won't work. What should I do? I want to call that function for many different objects and each object should have different ConstantForce (which depend on position of that object).
Should I convert my variables to vector? I read something about getWord() but I think that I didn't understand it entirely :)
And second question:
How does gravitic work? If I have constantForce == "10 0" it means that LinearVelocityX of that object will increase by 10 every second? And 10 is...? Pixels? Maybe it refer to Camera Size?
If I change the resolution in my game from 640x480 to 1024x768 and leave constant force same object will increase its speed slower?
About the author
I'm not from UK/USA so I'm sorry in advance for all grammatical mistakes :)
#2
Calling function with 2 int/float arguments works. I didn't expect that because I'm c++ programmer and there is big different between types :P
I thought if I will do something like that:
And you say that %string will be "5 10"?
Is that way to convert int/float to string/vector?
Which of that is/are correct? :
So LinearVelocity refer to "camera pixels" not real pixels, right?
(Anyway I always set Camera size to 1024x768 like real screen resolution ;))
11/09/2009 (4:52 pm)
Thanks for answer.Calling function with 2 int/float arguments works. I didn't expect that because I'm c++ programmer and there is big different between types :P
I thought if I will do something like that:
%x = 5; %y = 10; %string = "%x SPC %y";%string will be "%x SPC %y"
And you say that %string will be "5 10"?
Is that way to convert int/float to string/vector?
Which of that is/are correct? :
%x = 5; %y = 10; %string = %x SPC %y; //example 1 %string = "%x" SPC "%y"; //example 2 %string = "%x SPC %y"; //example 3 %string = "%x %y"; //example 4
So LinearVelocity refer to "camera pixels" not real pixels, right?
(Anyway I always set Camera size to 1024x768 like real screen resolution ;))
#3
You should know as a programmer that there is never any magic. All the engine does here is check the parameters and notes what was passed in (everything is passed in as strings). If that first parameter has two words in it, it assumes that you passed a space-separated vector. If it only has one word in it, it then goes under the assumption that the second parameter is the "y" value.
Being new to TGB, you should let the console be your friend. Bring up your application and press [Tilde] (~) or [Ctrl-Tilde]. You can then test various things. Like in the above, you can type the following lines into the console (you have to use globals to persist across lines in the console).
11/09/2009 (6:29 pm)
When I said "%ConstForceX SPC %ConstForceY", the quotes were not to be a part of that code. So, to be explicit:%x = 5; %y = 10; %string = %x SPC %y;
You should know as a programmer that there is never any magic. All the engine does here is check the parameters and notes what was passed in (everything is passed in as strings). If that first parameter has two words in it, it assumes that you passed a space-separated vector. If it only has one word in it, it then goes under the assumption that the second parameter is the "y" value.
Being new to TGB, you should let the console be your friend. Bring up your application and press [Tilde] (~) or [Ctrl-Tilde]. You can then test various things. Like in the above, you can type the following lines into the console (you have to use globals to persist across lines in the console).
$x = 5; $y = 10; $string = $x SPC $y; echo( $string );
#4
I'm using console all the time but I did it in other way - I was changing my scripts, adding echo(), reload project and than see what happens :) But as you know that is much more things to do than writing in console. I forgot that I can do that.
11/09/2009 (8:48 pm)
Thanks a lot :)I'm using console all the time but I did it in other way - I was changing my scripts, adding echo(), reload project and than see what happens :) But as you know that is much more things to do than writing in console. I forgot that I can do that.
#5
11/09/2009 (11:43 pm)
No problem!
Associate William Lee Sims
Machine Code Games
If it didn't work, you could build up your string by doing "%ConstForceX SPC %ConstForceY".
Gravitic means that the mass of the object is irrelevant. Thus, it your case, it will increase LinearVelocityX by 10 every second.
If your resolution changes, the t2dSceneWindow (typically) resizes, but the camera is still pointing to the same area. Therefore, 10 "pixels" might stretch to 20 real pixels, but the movement will be identical (relative to the other objects in the scene).