-
-
Notifications
You must be signed in to change notification settings - Fork 53
GameObjects : GameObjects Definition File
When you create a GameObject Class, there is only one mandatory file : The GameObject Defintion File (GODF), its file extension is .obj.vili
Here's the minimal GODF content for a GameObject Class named "SampleObject" :
SampleObject.obj.vili
SampleObject:
Note that the name of the main Vili Attribute MUST be the name of the GameObject.
The location of that file must be : Data/GameObjects/SampleObject/SampleObject.obj.vili
There is currently 4 components available for GameObjects :
(A)nimator Component :
String (path) : Path to the Animator root directory
String (default) : Default Animation Key
(C)ollider Component :
Template:Unit<?> (unit) : Unit of all the points of the polygon Collider
List<Float> (points) : All the points position of the polygon Collider
(For example, [1, 2, 3, 4, 5, 6] means 3 points at (1, 2), (3, 4) and (5, 6))
String (tag) : Tag of the Collider
List<String> (tags) : All the tags of the Collider (Ignored if tag is set)
String or List<String> (reject) : All the tags the Collider won't detect
String or List<String> (accept) : All the tags the Collider will detect (Excluding all others)
(L)evelSprite Component :
String (path) : If Animator Component not used, path of the image used
Template:Rect<?> (rect) : Rect of the LevelSprite containing x, y, width, height
Int (layer) : Layer of the LevelSprite
Int (z-depth) : Z-depth of the LevelSprite
Float (rotation) : Rotation of the LevelSprite
String (xTransform) : Position Transformer for the x Coordinate (Position, Camera or Parallax)
String (yTransform) : Position Transformer for the y Coordinate (Position, Camera or Parallax)
(S)cript Component :
Int (priority) : Priority of script execution (Biggest is first executed)
String (source) : Source code of the GameObject to load (It's a path to a .lua file)
List<String> (sources) : List of source code of the GameObject to load (Ignored if source is set)
For example if you want an object with only a Script component, it could look like that :
SampleObject:
Script:
source:"Data/GameObjects/SampleObject/SampleObject.lua"
priority:1
Using multiple composants obviously works too :
SampleObject:
Collider:
unit:Unit<WorldUnits>()
points:[0.1, 0.1
1.0, 0.1
1.0, 1.0
0.1, 1.0]
tag:"Player"
reject:["Invisible", "Water"]
Script:
sources:["Data/GameObjects/SampleObject/SampleMovements.lua",
"Data/GameObjects/SampleObject/SampleColor.lua"]
priority:2
As you can see, it's a bit complicated to create object by hand, that's why the Toolkit can helps a lot !
Type the following command in the toolkit :
object create ObjectName CLAS
The "CLAS" part is the list of the components you want to use in your GameObject :
- C for Collider
- L for LevelSprite
- A for Animator
- S for Script
Add or remove those letters to add / remove components in the GODF !
Let's now see how you can add GameObjects to a Scene
- 🖊 My first project
- 🗺 My first map
- 📏 Project Structure
- 🖼 LevelSprites
- 📐 Colliders
- 🔳 EditorGrid
- 🤖 GameObjects
- 🖊 Scripting
- 🔫 Events
- 📜 Read the Docs
- ⌨️ Keyboard and Actions
- 👨💻 Debugging
- 🔉 Sounds and Musics
- 🗄 Vili Format
- 📽 Animations
- ✂️ Using Utils
- ⌚️ Manipulating Time
- 🎨 Using the Canvas
- ✔️ Tasks
- 🖱 Cursor and Constraints
- ⌨️ Keyboard and Actions
- 📁 Mounting and Paths
- 👨🏭 Workspaces
- 📏 Coordinates and Transform
- 📷 Camera
- 🗺 Map files
- 🏭 The ResourceManager
- 🎮 Gamepads and Joysticks