Spotlight: Treyreynolds’ Thrilling Gameplay Scripts
If you’ve ever been high in the atmosphere on a plane or nearly touched the clouds in a sky-scraper, you might have found yourself pondering the idea–no, not acting on it–of jumping out and experiencing flight. You’re not the only one. We humans have dreamed of flight for generations, and have done everything from jumping out of planes to inventing rockets to experience the feeling. That’s a big reason why Air Physics, Skydiving and Flight by treyreynolds initially caught my eye (and the eyes of more than 200,000 other visitors, I should mention). In any other ROBLOX game, falling from great heights feels approximately the same. Treyreynolds wanted to change all that, so he scripted a complex air-physics script to do it. When I started to dig into what else treyreynolds has been doing around ROBLOX, I found some innovative stuff.
In Air Physics, Skydiving and Flight, you free fall through wide-open air with full control of your body on the way down. Standard movement controls apply, though hitting “w” to move “forward” during a free fall means you will fall faster (which is reflected visually by your body becoming much more rigid) and “s” will slow your fall (reflected by a sort of spread eagle position you’ve probably seen in skydiving videos). It’s a neat trick to be sure–I talked with treyreynolds about developing the system.
“Basically I was tired of falling through the baseplate every time I took a huge leap,” he recalls. “So I thought about making a terminal-velocity script that could make a character, or rather, all entities, fall at a maximum velocity based on their size, mass, and orientation.”
Easier said than done, but the scripting side of achieving this taught him much about advanced ROBLOX scripting and physics altogether.
“I had to approach coding this differently. I realized that I could apply force from the volume of air that was perpendicular to the side of parts, as opposed to against the current velocity of the part,” he recalls. “So the greater volume of air that needs to be moved, the more force would be applied to the side that was pushing it. Fun!”
In order to create realistic falling movements, treyreynolds developed an animation system that makes ROBLOX characters move in a way that you probably haven’t seen before. Free falling, running and crouching all have a unique look created with advanced scripting.
“The script makes a joint half way through a part, then I created a function that I feed a point. This gives me the orientation the leg should be in. It’s basically just a lot of CFrame math. And math, and math.”
He goes on to explain that these animations are a sort of baseplate for a climbing script he’s been working on, which would allow ROBLOX characters to climb on models with no set up beforehand. I was having difficulty determining what exactly he meant by that–luckily he had a demo on hand to show me.
Treyreynolds Place Number: 30 is, like many of treyreynolds’ places, a scripting experiment. In it are tall structures lined with small red cubes that function as a visualization of “grip” points that tell the script the best places to grab–it’s very much functional, though the animations haven’t been completed yet. To begin climbing, walk up to any of the structures and hit “e”. Then watch as your ROBLOX avatar begins ascending, grabbing onto elevated points throughout the climb.
“The animations are pretty preliminary, but the hand-hold-point-finding method is done,” he tells me. “The system itself is very complicated.”
I ask him to explain the method in a way that a journalist with no background in programming would understand–he opted to explain the method in numbered steps. I’ll share that explanation with you now.
- Find all parts in your workspace.
- Find which parts are applicably close to you.
- Of those parts, find the faces that are facing upward.
- See if those faces are applicable.
- Find all four edges of each face.
- Find the hand hold points closest to your character on all four edges.
- Make one virtual sphere (not a new instance and not physics based).
- Make another sphere in front of the grab point.
- See if the user can see the point from both the head and torso.
- See which points are applicable from there.
- Animate the character.
Treyreynolds is pushing the boundaries of how ROBLOX characters can move–he’s the type of developer we love having. He’s experimenting to find ways to solve complex problems and contributing to our ecosystem of creation. He’s even sharing his scripts, meaning any ROBLOX Developer can implement them in their game. I couldn’t help but ask, “why share your hard work with everybody?” This was his answer:
I don’t like giving out fully functioning scripts, because then people can just take them and the credit for creating them. I give out versions that are inferior to the ones in my game, and upload them as models for people to play around with. The scripts I give out aren’t really good enough to use in a game, they’re just meant to increase interest, and hopefully inspire people to make their own. It’s an honor thing, really. If a person is good enough at coding and math to be able to create his or her own code, I’ll give mine up, because I know that that person is going to do something substantial with it.