Difference between revisions of "GameObj"
(→Game Object Properties) |
(→Game Object Properties) |
||
Line 6: | Line 6: | ||
**Getting the Id of a gameObject: <code>mId = mObj.Id</code> | **Getting the Id of a gameObject: <code>mId = mObj.Id</code> | ||
** Setter: Gameobject Ids cannot be set. They are created and assigned by the engine on object creation. | ** Setter: Gameobject Ids cannot be set. They are created and assigned by the engine on object creation. | ||
− | **Referencing a | + | **Referencing a gameobject from a known Id(=number): <code>mGameObj = GameObj(mId)</code> |
+ | |||
* '''<code>Name</code>''': The name of a gameobject, visible in game. | * '''<code>Name</code>''': The name of a gameobject, visible in game. | ||
**Getter: <code>mName = mObj:GetName()</code> | **Getter: <code>mName = mObj:GetName()</code> | ||
**Setter: <code>mObj:SetName("Samogh the Blacksmith")</code> | **Setter: <code>mObj:SetName("Samogh the Blacksmith")</code> | ||
− | Hue | + | * '''<code>Hue</code>''': The hue of an object which mixes with the texture colors. You cannot force an object to be magenta, when its texture color is green. |
+ | ** Getter: <code>mHue = mObj:GetHue()</code> | ||
+ | ** Setter: <code>mObj:SetHue("FF0000")</code> | ||
+ | |||
+ | * '''<code>Location</code>''': Location of the object in the world | ||
+ | ** Getter: <code>mLoc = mObj:GetLoc()</code> | ||
+ | ** Setter: <code>mObj:SetWorldPosition(Loc(0,0,0))</code> The example positions the object at the world origin. | ||
+ | ** Setter2: <code>mObj:MoveToContainer(mBag, Loc(0,0,0))</code> Object gets put into container mBag at relative coordinates 0,0,0 inside the container. | ||
+ | ** You can use SetWorldPosition() to move an object out of a container into the world. | ||
+ | |||
+ | * '''<code>Rotation</code>''': Rotation of the object in its own local coordinate system | ||
+ | ** Getter: <code>mRot = mObj:GetRotation()</code> Returns a Loc object whith three angles in degrees which describe the object rotation around the axis x,y and z. The order of rotation is: z, y, x (The Unity standard of rotation) | ||
+ | ** Setter: <code>mObj:SetRotation(Loc(45,30,60))</code> The example sets the rotation of the object to 60° around its Z axis, 45° around its X axis and 30° around its Y axis. | ||
+ | |||
+ | * '''<code>Scale</code>''': Scaling of the object in its own local coordinate system | ||
+ | ** Getter: <code>mRot = mObj:GetScale()</code> Returns a Loc object whith three scale factors which describe the object scaling in each axis x,y and z. | ||
+ | ** Setter: <code>mObj:SetScal(Loc(2,4,2))</code> The example sets the scale of the object to 2x at its x and Z axis, and 4x at its X axis. So it is 2 times taller than wide and stretched up high (y-axis). | ||
== Tips == | == Tips == |
Revision as of 12:56, 1 November 2016
Game Object (GameObj) is a Dynamic object within the game that can occupy a position of the world, including a Container. Game Objects are the most common of all Objects and can have Variables and/or Modules attached to them.
A potion, a monster, a door, and a sword are all examples of GameObjs.
Game Object Properties
Id
:The unique Id of a GameObject, Ids are unique on a per cluster basis.- Getting the Id of a gameObject:
mId = mObj.Id
- Setter: Gameobject Ids cannot be set. They are created and assigned by the engine on object creation.
- Referencing a gameobject from a known Id(=number):
mGameObj = GameObj(mId)
- Getting the Id of a gameObject:
Name
: The name of a gameobject, visible in game.- Getter:
mName = mObj:GetName()
- Setter:
mObj:SetName("Samogh the Blacksmith")
- Getter:
Hue
: The hue of an object which mixes with the texture colors. You cannot force an object to be magenta, when its texture color is green.- Getter:
mHue = mObj:GetHue()
- Setter:
mObj:SetHue("FF0000")
- Getter:
Location
: Location of the object in the world- Getter:
mLoc = mObj:GetLoc()
- Setter:
mObj:SetWorldPosition(Loc(0,0,0))
The example positions the object at the world origin. - Setter2:
mObj:MoveToContainer(mBag, Loc(0,0,0))
Object gets put into container mBag at relative coordinates 0,0,0 inside the container. - You can use SetWorldPosition() to move an object out of a container into the world.
- Getter:
Rotation
: Rotation of the object in its own local coordinate system- Getter:
mRot = mObj:GetRotation()
Returns a Loc object whith three angles in degrees which describe the object rotation around the axis x,y and z. The order of rotation is: z, y, x (The Unity standard of rotation) - Setter:
mObj:SetRotation(Loc(45,30,60))
The example sets the rotation of the object to 60° around its Z axis, 45° around its X axis and 30° around its Y axis.
- Getter:
Scale
: Scaling of the object in its own local coordinate system- Getter:
mRot = mObj:GetScale()
Returns a Loc object whith three scale factors which describe the object scaling in each axis x,y and z. - Setter:
mObj:SetScal(Loc(2,4,2))
The example sets the scale of the object to 2x at its x and Z axis, and 4x at its X axis. So it is 2 times taller than wide and stretched up high (y-axis).
- Getter:
Tips
- Obj variables should only contain data you are intending to persist to disk, especially since reading from an ObjVar immediately after setting it will not always return the new value.
- GameObj can communicate between each other using SendMessage just like Modules.