Create Account

Laying the Groundwork for a Physics-Based Sim
#1
(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.

[Image: cmS4zaU.png]

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.

[Image: aUnfc8n.png]

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

[Image: premierbromanov.gif]




Fuck the penaltys
ARGARGARHARG
[Image: EePsAwN.png][Image: sXDU6JX.png][Image: eaex9S1.png]
Reply
#2

@.bojo finishing blockey?

MWHazard Wrote:i'll playwith anyone
playing with my teammates is part of the intangibles I bring to the table
i play with them a lot.
they didn't like it at first
but after a while, it just felt normal
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
HIRE ARTY
[Image: xuHy0EF.png]
[Image: Artermis.gif]
Reply
#3

02-18-2023, 06:11 PMartermis Wrote: @.bojo finishing blockey?

is that trademarked

[Image: premierbromanov.gif]




Fuck the penaltys
ARGARGARHARG
[Image: EePsAwN.png][Image: sXDU6JX.png][Image: eaex9S1.png]
Reply
#4

Sick

[Image: downer.gif]



[Image: SyiOY8U.png]
Reply
#5

This is awesome stuff!

[Image: 3WSeHAA.png]
Reply
#6

02-18-2023, 06:22 PMPremierBromanov Wrote: is that trademarked

in my heart

MWHazard Wrote:i'll playwith anyone
playing with my teammates is part of the intangibles I bring to the table
i play with them a lot.
they didn't like it at first
but after a while, it just felt normal
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
HIRE ARTY
[Image: xuHy0EF.png]
[Image: Artermis.gif]
Reply
#7

We'll make our own sim engine, with blackjack, and hookers.

[Image: 65151_s.gif]





[Image: Tqabyfh.png] [Image: OOcGSpM.png]
Reply
#8

02-18-2023, 07:46 PMbrickwall35 Wrote: We'll make our own sim engine, with blackjack, and hookers.

Blackjack optional?

[Image: Wally.png]






Reply
#9

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 Smile

[Image: EdmTeamPhoto.png?ex=6605c039&is=65f34b39...height=623]
Edmonton Blizzard Co-GM
Yukon Malamutes Hall of Fame
[Image: NwdnVLP.png][Image: fDB9MNX.png] 
[Image: 3j8MIXU.png]
Granny Panpan Count: 258
Reply




Users browsing this thread:
1 Guest(s)




Navigation

 

Extra Menu

 

About us

The Simulation Hockey League is a free online forums based sim league where you create your own fantasy hockey player. Join today and create your player, become a GM, get drafted, sign contracts, make trades and compete against hundreds of players from around the world.