rotationOffset
by rennie moffat · in Torque Game Builder · 10/03/2009 (12:58 pm) · 10 replies
I have a question regarding this line of code,
it was taken from the faceObject Behavior. I am just wondering, rotationOffset, is not found in any base code. It is not a spatial method of objects, so this person must have wrote it, or is there something I am missing where you can add terms like rotation and offset, separately base terms? I ask becasue I wonder how the computer is calulating something that is not native to it.
full code
%targetRotation = mRadToDeg(mAtan(%vector.y, %vector.x)) + 90 + %this.rotationOffset;
it was taken from the faceObject Behavior. I am just wondering, rotationOffset, is not found in any base code. It is not a spatial method of objects, so this person must have wrote it, or is there something I am missing where you can add terms like rotation and offset, separately base terms? I ask becasue I wonder how the computer is calulating something that is not native to it.
full code
//-----------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
if (!isObject(FaceObjectBehavior))
{
%template = new BehaviorTemplate(FaceObjectBehavior);
%template.friendlyName = "Face Object";
%template.behaviorType = "AI";
%template.description = "Set the object to face another object";
%template.addBehaviorField(object, "The object to face", object, "", t2dSceneObject);
%template.addBehaviorField(turnSpeed, "The speed to rotate at (degrees per second). Use 0 to snap", float, 0.0);
%template.addBehaviorField(rotationOffset, "The rotation offset (degrees)", float, 0.0);
}
function FaceObjectBehavior::onBehaviorAdd(%this)
{
%this.owner.enableUpdateCallback();
}
function FaceObjectBehavior::onUpdate(%this)
{
if (!isObject(%this.object))
return;
%vector = t2dVectorSub(%this.object.position, %this.owner.position);
%targetRotation = mRadToDeg(mAtan(%vector.y, %vector.x)) + 90 + %this.rotationOffset;
if (%this.turnSpeed == 0)
%this.owner.setRotation(%targetRotation);
else
%this.owner.rotateTo(%targetRotation, %this.turnSpeed, true, false, true, 0.1);
}About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
Going on this while I have you tho are most things able to be "offset", "get", "set", so if I dont see it as a written method, it is safe the compiler will understand it?
10/04/2009 (6:19 pm)
I see that but I was looking thru the base code, from the documents and could not see it. So I thought perhaps it was a creation of this writer. Am I wrong?Going on this while I have you tho are most things able to be "offset", "get", "set", so if I dont see it as a written method, it is safe the compiler will understand it?
#4
10/04/2009 (9:22 pm)
I'm not sure that answers my question. I am just wondering, since specifically setRotation was not found in spatial methods of objects so, I was wondering if this is something Torque understands, the prefix of "set" combined with something like "rotation" or, as I know there is "linearVelocity".
#6
10/05/2009 (1:17 am)
I could find setRotation, but I dont think you are understanding my question. I could not find "rotationOffset" could you? I have no problem finding setRotation. It is just a question to help me better understand the coding language and it's potential flexibility.
#7
"I was wondering if Torque understands... 'set' combined with... 'rotation'"
So what part of your question did I not understand? If you are wondering where rotationOffset came from, that should be your question. And if that IS your question, please refer to Line 16 and the Creating Behaviors tutorial.
10/05/2009 (11:11 am)
"setRotation was not found in spatial methods of objects""I was wondering if Torque understands... 'set' combined with... 'rotation'"
So what part of your question did I not understand? If you are wondering where rotationOffset came from, that should be your question. And if that IS your question, please refer to Line 16 and the Creating Behaviors tutorial.
#8
10/05/2009 (11:54 am)
oops, my bad, damn dyslexia. however I did read line 16. Ok yes I do know it comes from there, but my question, being more specific is that rotationOffset, as is, is simply a float. A float could determine velocity, how in this case, does it recognize it as degrees since "rotationOffset" is not part of the core language?
#9
Does this mean the language has evolved since the documentation? ie, this tutorial is more recent than the TDN TGB docs regarding language only?
10/05/2009 (1:01 pm)
Hi William, here is a good question for me regarding all this coding bizznass. :). I am working on just typing out the UFOMovement, and am on the the part of guiding it, directing its movement. and came across the tiniest nugget that actually controls is HorizontalSpeed. The have named it HorizontalSpeed, not LinearVelocityX or xVelcoity, the two common terms I have for it from the Core Language Docs.Does this mean the language has evolved since the documentation? ie, this tutorial is more recent than the TDN TGB docs regarding language only?
#10
I just saw, I saw setImpulseForce, So I think that negates my question.
I was looking in the wrong part of the line.
HorizontalSpeed was significant not setImpulseForce, but am sorry. and I just noticed Horizontal speed in the upper section of the code. I apologize, but i seem to have to have to think things out e loud.
Thanks
Ren
10/05/2009 (1:15 pm)
Hi William, I just saw, I saw setImpulseForce, So I think that negates my question.
I was looking in the wrong part of the line.
HorizontalSpeed was significant not setImpulseForce, but am sorry. and I just noticed Horizontal speed in the upper section of the code. I apologize, but i seem to have to have to think things out e loud.
Thanks
Ren
Associate William Lee Sims
Machine Code Games