Join me in a one-hour Discord stream where we build something based on the community’s prompt! It can be art, UI or a mechanic inspired by another game – or just something that you would like to implement in your game and that is not yet in the Community Content. Come pitch the idea and I’ll stream making it, along with answering questions about scripting.
The goals of these sessions are to:
- Learn how to build things in Core by looking at someone else.
- Answer your questions while making the content.
- Publish the content created during the stream in the Community Content.
The sessions are intended for beginners but advanced creators who want to learn to script will find value as well. An assignment for the next week will be given at the end of the stream for people that want to try by themselves.
Next session: Monday at 10am PT (7pm CEST)
Where: Creators Discord, Voice channel #Event-Moderated
See you all on Monday
27 Sept. 2021
Goal of this session
Make a Tornado Ability that makes the player dash in front of him.
What we covered
- Ability and Equipment
- Spawn an Object
- Script an Ability
- VFX and SFX for a Tornado
- Lua Good Practices: Constants and Custom Properties
- Damageable Objects
- Add Resource and Resource Display
Timecodes of each part
0:00 - Equip an Ability when the player joins
4:38 - Testing and Prototyping: Looking for a solution to move the player
13:20 - Planning the solution
14:29 - Spawn an object
17:50 - Attach a player to a moving object
20:57 - Constants in Lua and Custom Properties
25:34 - Add Tornado VFX in Client Context
27:18 - Trying to change the system but rolling back
33:19 - Find the destination of the dash (Forward and Transform)
36:19 - Polish code, SFX, player animation
51:35 - DamageableObject Crates
59:26 - AddResource Gems when breaking Crates
Template of the system
PBT file (drop it in your Core window and then drag and drop the template TornadoGame in your scene)
Left-click to use the Tornado Dash Ability
I had to fix two bugs after the live:
- Use FindDescendant and not FindChild to find the Tornado as it is a child of TornadoGame by default (this can be enhanced by doing the second basic challenge given just above)
- Sometimes the dash was not in the correct direction because I was looking at the transform after attaching the player to the object, which was changing the rotation in a specific direction. A comment has been added to explain what changed.
(click to open) Main Script - AbilityDash
local ABILITY = script.parent
-- BUG FIX: this method to find the Tornado is not great because it is only working for one player
-- I changed FindChild to FindDescendant because the tornado is by default in the group TornadoGame
local TORNADO = World.GetRootObject():FindDescendantByName("Tornado")
local TORNADO_DURATION = ABILITY:GetCustomProperty("TornadoDuration")
local TORNADO_RANGE = ABILITY:GetCustomProperty("TornadoRange")
local player = ability.owner
local playerPos = player:GetWorldPosition()
TORNADO.visibility = Visibility.FORCE_ON
-- BUG FIX: this line is moved to line 26 because it was modifying
-- the transform of the player so the dash was not based on the player direction
local player = ability.owner
local forward = player:GetWorldTransform():GetForwardVector()
local finalVector = player:GetWorldPosition() + forward * TORNADO_RANGE
TORNADO.visibility = Visibility.FORCE_OFF
- Enable the Trigger that destroy the crates only during the dash (currently you can just walk and destroy crates, you will have to toggle the collision of the Trigger at the right place)
- Instead of using FindDescenntByName to find the Tornado, spawn one Tornado per player and store the object reference of that Tornado somewhere (maybe ABILITY.serverUserData.tornado = TORNADO?)
- More explosion and feedback to the player
- Make a game that reaches 200+ plays with the tornado dash as the main mechanic.