Laying the Groundwork for a Physics-Based Sim
|
PremierBromanov
Registered Cool guy
02-18-2023, 06:06 PM
(This post was last modified: 02-18-2023, 06:12 PM by PremierBromanov. Edited 1 time in total.)
For fun today, I laid the groundwork for a physics based hockey sim using Unity. I thought I would write a bit about that. Here's a short video you can watch of what I came up with. This took about 2 and a half hours and is of course incredibly simple.
Video Here I will explain how this sim works in a moment. But first... Why? For awhile now, I've lamented two main things about FHM. Number one, it's bad to look at. Number two, I don't know how it works. I can solve both of these issues for by making a sim. But more than that, I want to be creative and this is a good outlet. Of course, there are a myriad of problems with FHM and I think all of them are exasperated by the fact that the sim is so incredibly obscure. As it has always, the sim comes down to a few numbers. That makes it difficult to see how good of a defender you might be, or what type of player you're creating. Sure, you can make a big body and hope your GM employs him in a way that helps you hit. And you can look at your hits count. but the hits mean nothing to us, beyond what our imaginations will tell us. And the same with scoring. Is your player Joe Pavelski, tipping pucks in from 100 feet away, or is your player Ovechkin, taking clappers from the red dot. perhaps you wanted to emulate McDavid's incredible speed and hands. Its hard to see what exactly your player is good at. Or perhaps you wanted a playmaking genius like Datsyuk, or a great setter like Kucherov. Is your defender solid on the blue line? Does he get in the mix offensively, or is he taking shots from the outside? Does he walk the puck up and down the line like Mike Green? It's hard to tell... And all of that is fine. Collectively, the SHL has grown into a flourishing community with material impacts on our lives. We don't need to replace FHM. But, I do want to move towards a fun alternative. Maybe for special events, fund raising, or general tomfoolery. At the end of the day, I just want to see what I can come up with. Can I make building a player fun and engaging? Can I put the tools in the hands of users to create whatever player they can think of? How does the sim work right now? It bears explaining how this sim works, because I want you to understand what the goal is and I want you to believe me when I say I'm on the right path. It's also important to remember that everything in here has some data attached to it. Each data point can be changed. What we change and how we change it is a matter of creating a "player builder" on top of all of this. Size, weight, position, force, even behaviours. If you can think it, we can control it. Here is the player. Our player is a capsule with a collider. He has a rigidbody attached to him, which means he is part of the Unity physics engine. He collides with the floor, the puck, the walls, and other players. Anything with a collider can be collided with. He also has a puck handler (the green box). More on that later. He also has a few stats, and these are raw stats. Meaning, they haven't been translated to a user-friendly metric. Acceleration: This is the force applied to the player every frame in terms of "per second". The force is applied in a direction vector that is equal to the player's forward vector (that little blue arrow) Max Speed: Currently unused. Before, I had been controlling the velocity of the player directly, but that puts constraints on other players potentially forcing this player to go "too fast" by hitting them very hard. Rather, we want to work in forces here. Steering Acceleration: How many degrees per second can the player rotate? With a value of 180, it takes 2 full seconds for the player to make a complete rotation Pucklhandling Force: The force applied to the puck towards the center of the puck handler while it is within the zone of control. Higher forces make it more difficult to lose it. Shooting Strength: How much impulse force we apply to the puck. As you can see, it's quite low. None of these stats are final, but they illustrate a point: We can change how the player plays by modifying values that interact with the physics system. Moreover, we can change how we PERCIEVE the player to be playing by changing these values. At the start, the Player is in "Chase puck" mode. His "Target" is set to the Puck. The player moves towards his target always. In the future, a target may be a point on the ice, even a series of points, or a player. It's not yet implemented, but avoidance is also a key part of their trajectory. They will seek to avoid players who do not have the puck, perhaps according to some attribute or playstyle. When the Player's puckhandling zone touches the puck, a force is applied to the puck to mimic puckhandling. Multiple players can vie for control of the puck at once, meaning usually the stronger puckhandler will win, but there are other potential factors at play, such as skating strength and player weight. Can you really get to the puck if you cant out-muscle the opponent? The puckhandling zone size can change. We could even think about moving it around, the way a stick would. After the puck enters the puckhandling zone, this player moves to "score goal" mode. His new target is a goal, a solid cubic meter of...stuff. Since his new target is the goal, he will skate towards it. However, when he is within about 5 meters, he shoots the puck. We apply a one-time force on the puck in the direction of the goal, with some inaccuracy. In this case, we generate a random point on a sphere inside the goal. That is the direction of the force. Thus, you can see the player misses the net sometimes. You may notice the player doesnt even face the goal to get the shot off. This is a behaviour we can change, and I think would open the door to customization. Once the puck is shot, the player re-enters chase puck mode, and the cycle continues. I have a lot of ideas on what I'd like to do with this, if I ever get the motivation to sit down with it again. The Sim is a small piece of a much larger whole. The infrastructure required to merely create a player, much less a team with schedules and tournaments, is quite large. But, if I play my cards right, i can make this scalable and modular. Here's a bit of inspiration I've been using. I've made boid systems before. For players, it's not necessarily applicable, because we dont want them to move as a flock. But, we do want them to be conscious of other players and obstacles. Boids can easily be programmed to do that, as you'll see in the tutorial. Instead of following a flock's central point, we can rather follow a single target. Maybe that target moves, maybe it doesnt. It's all pretty much the same kind of math
artermis
IIHF Commissioner Patron Saint of the SMJHL
@.bojo finishing blockey?
MWHazard Wrote:i'll playwith anyone Justice,Sep 18 2016, 02:09 PM Wrote:4-0 and 0-4 aren't that different tbh McJesus - Today at 10:38 PM Wrote:FIRE EGGY
PremierBromanov
Registered Cool guy
CapnCooper
SHL GM SHL GM
artermis
IIHF Commissioner Patron Saint of the SMJHL 02-18-2023, 06:22 PMPremierBromanov Wrote: is that trademarked in my heart MWHazard Wrote:i'll playwith anyone Justice,Sep 18 2016, 02:09 PM Wrote:4-0 and 0-4 aren't that different tbh McJesus - Today at 10:38 PM Wrote:FIRE EGGY
brickwall35
SMJHL HO BoFA
Wally
SHL GM El Dumbo - Big Spoon - Both Handed
Eggcracker
All-Star Committee egg egg egg egg egg egg egg egg
This is amazing! I love the idea and the creativity, hope this passion project comes to life. Although I don't understand the complexities of something like this, i am very interested to see how this goes
Edmonton Blizzard Co-GM
Yukon Malamutes Hall of Fame
Granny Panpan Count: 258
|
« Next Oldest | Next Newest »
|
Users browsing this thread: |
1 Guest(s) |