Frustrating documentation for iTorque2D - example t2dPath
by Nigel Bond · in Technical Issues · 06/08/2011 (5:06 am) · 4 replies
I have been trying out the t2dPath functionality.
I created a path in the GUI, put an object on it and watched it move. All good.
I then added another object to the screen and made them collide; and picked up the collision in script, so far so good. I intended to make the object reverse its direction on colliding but then a whole world of pain descended on me.
It does not seem possible to reverse the direction of the object on the path even though there is a moveForward method. It is not documented in iTorque2D more than the method name and parameters. Ok, so that did not work. If I click it in the GUI and run it does go the other way but it seems it is a setup setting and not a mid flow thing. Ok, lets set the speed to be negative - it bounced off in some other direction off the path. Ok, set the endNode, it resets to the node and starts again(this actually made me happy considering the progress I had been getting). Ok, I will make it do that faster and faster(just for kicks). Code below,
%srcObj.getAttachedToPath().setSpeed(%srcObj,%srcObj.getAttachedToPath().getSpeed() + 1);
%srcObj.getAttachedToPath().setEndNode(%srcObj, 2);
But no, the set speed made it just reset and not move.
I worked out I could get understanding from the C++ for this class, but please someone tell me it can be easier than this to solve problems.
I have done C++ before amongst about 10 other languages, I just want the documentation set and perhaps some basic usage tips per class. See the Java docs for what I find perfect.
Any help would be appreciated, my progress is stunningly slow, it cannot be this hard, can it?
Thanks in advance
Nigel
I created a path in the GUI, put an object on it and watched it move. All good.
I then added another object to the screen and made them collide; and picked up the collision in script, so far so good. I intended to make the object reverse its direction on colliding but then a whole world of pain descended on me.
It does not seem possible to reverse the direction of the object on the path even though there is a moveForward method. It is not documented in iTorque2D more than the method name and parameters. Ok, so that did not work. If I click it in the GUI and run it does go the other way but it seems it is a setup setting and not a mid flow thing. Ok, lets set the speed to be negative - it bounced off in some other direction off the path. Ok, set the endNode, it resets to the node and starts again(this actually made me happy considering the progress I had been getting). Ok, I will make it do that faster and faster(just for kicks). Code below,
%srcObj.getAttachedToPath().setSpeed(%srcObj,%srcObj.getAttachedToPath().getSpeed() + 1);
%srcObj.getAttachedToPath().setEndNode(%srcObj, 2);
But no, the set speed made it just reset and not move.
I worked out I could get understanding from the C++ for this class, but please someone tell me it can be easier than this to solve problems.
I have done C++ before amongst about 10 other languages, I just want the documentation set and perhaps some basic usage tips per class. See the Java docs for what I find perfect.
Any help would be appreciated, my progress is stunningly slow, it cannot be this hard, can it?
Thanks in advance
Nigel
#2
%srcObj.getAttachedToPath().setSpeed(%srcObj,%srcObj.getAttachedToPath().getSpeed() + 1);
Should be
%srcObj.getAttachedToPath().setSpeed(%srcObj, %srcObj.getAttachedToPath().getSpeed() + 1, 0);
Notice the 0 (or false) parameter at the end. The same goes for a function like setMoveForward which takes in the object, a boolean for forward or not and a boolean for reset.
06/08/2011 (6:26 am)
Alright, so I was wrong on a point. Some functions allow you to determine whether a reset happens or not. For example:%srcObj.getAttachedToPath().setSpeed(%srcObj,%srcObj.getAttachedToPath().getSpeed() + 1);
Should be
%srcObj.getAttachedToPath().setSpeed(%srcObj, %srcObj.getAttachedToPath().getSpeed() + 1, 0);
Notice the 0 (or false) parameter at the end. The same goes for a function like setMoveForward which takes in the object, a boolean for forward or not and a boolean for reset.
#3
06/08/2011 (6:26 am)
I'll do another pass on the t2dPath doc to get this functionality covered.
#4
I appreciate you taking the time to reply. So its 4:43am here and I woke up with a thought,
echo("get path speed for obj :" SPC %srcObj.getAttachedToPath().getSpeed(%srcObj));
%srcObj.getAttachedToPath().setSpeed(%srcObj, %srcObj.getAttachedToPath().getSpeed(%srcObj) + 5);
%srcObj.getAttachedToPath().setEndNode(%srcObj, 2);
echo("get path speed for obj (after):" SPC %srcObj.getAttachedToPath().getSpeed(%srcObj));
I need to get the speed on the pathed object not just getSpeed() as I was doing. Sorry it was late and I did not look at my debug console. The code defaults to 0(not reset) so I left that off.
It would be cool to see the tutorial go further and show some clever stuff like changing direction etc.
Thanks again
Nigel
06/08/2011 (9:47 am)
Michael,I appreciate you taking the time to reply. So its 4:43am here and I woke up with a thought,
echo("get path speed for obj :" SPC %srcObj.getAttachedToPath().getSpeed(%srcObj));
%srcObj.getAttachedToPath().setSpeed(%srcObj, %srcObj.getAttachedToPath().getSpeed(%srcObj) + 5);
%srcObj.getAttachedToPath().setEndNode(%srcObj, 2);
echo("get path speed for obj (after):" SPC %srcObj.getAttachedToPath().getSpeed(%srcObj));
I need to get the speed on the pathed object not just getSpeed() as I was doing. Sorry it was late and I did not look at my debug console. The code defaults to 0(not reset) so I left that off.
It would be cool to see the tutorial go further and show some clever stuff like changing direction etc.
Thanks again
Nigel
Employee Michael Perry
ZombieShortbus