GameDev Blog: Goblin Rules Football #24: Wind and Club Sprites

Hello! And welcome to my humble blog about making a golf mode for my already published game, Goblin Rules Football. In my previous post, I mentioned adding a “target” at the end of the trajectory that the camera would focus on as the player aims their hit. Well, I did it! Here’s a screenshot from the game:

As I continue to blatantly rip off Golf Story, I added a dashed line material to my trajectory line leading up to the landing target. To create the dashed line, I followed Binary Lunar’s tutorial “Animated Dashed Curvy-Line Shader Graph for Level Map – Easy Unity Tutorial” on YouTube. Their tutorial also deals with animating the line and making it partially filled on the line’s path, which I ignored since I didn’t need to use it. They also use BG Curve with their line render to creating the curving line, which again I didn’t need so I didn’t use. One thing to note is that to change how often the material “tiles” so that the dashed line repeats, you just need a reference to the material in your script and then do something like this:

_trajectoryLineMaterial.SetFloat("_Tiling", <float value>);

Similar to how to can send information to other Unity stuff, like the animator, you can use the “.SetFloat()” method to change values of a material during gameplay. I used this to make sure the number of dashes stayed consistent regardless of how long the line was.

The next thing I worked on was “wind” in the game. I wanted their to be wind that would affect the trajectory of hit balls. I didn’t want the drawn trajectory to take wind into account, though. I only want the drawn trajectory to show the player where they are aiming, not a precise calculation of where their shot will land. So, things like wind wouldn’t be reflected in the trajectory, making one of the challenges or “Skills to develop” of the game learning how to compensate your aim for the wind speed.

To do this was fairly simple. My ball trajectories are done using Bézier curves. Basically, you calculate 3 points, a start point, end point, and mid (or “control”) point, and then lerp the objects between them. So, for the wind, I just simply calculated a wind “force” by multiplying the wind direction by the wind speed (in MPH) and finally by a value based on the balls max height for the hit (higher the ball, higher the value). The last height value is used to make it so balls that are hit higher are effected by the wind more. This allows for players to sort of “cut into” the wind with higher top spin, since the spin will lower the angle of the hit and thus the max height of the hit.

The calculated wind force is then added to the end point of the trajectory, and to the mid point of the trajectory (but divided by 2). This seems to simulate adding a wind force consistently on the shot. It certainly isn’t accurate physics, but good enough for this game, I think.

Then to display this to the player, I created a simple arrow indicator with the speed below, completely ripping off Golf Story once again.

One thing that may be embarrassing to admit is that updating the wind indicator whenever wind direction/speed changes for this prototype is probably the first time I’ve used events and delegates in a Unity project, outside of for some of the built-in unity stuff like UI events. In my multiplayer games I made heavy use of SyncVars with hook functions, which are similar to events/delegates but not quite the same. Anyway, it was nice to do. I always found how events worked confusing but I’m also a dumb baby developer so ¯_(ツ)_/¯

And, finally, the new club sprites! Look at them!


Wow! And now everything in video?

Simply amazing content. You can see in the above video that I didn’t turn off the drawn trajectory. That was to show the effect of the wind on the hit. It looked ok if you ask me!

Next Steps…

Hmm, what next? I was thinking off adding some more weather effects, like rain maybe. Rain could be something that slows down rolls, reduces bounces on the ground, and “dampens” your hit by lowering the actual max height it will achieve (relative to a “no rain” hit). Idk. Something like that.

Also, I want to add sand traps and other hazards. At least get a basic idea of one work. Instantly stops bouncing if in the trap, clubs take max distance reductions based on the trap, can’t use a putter, etc./whatever.

Smell ya later, nerds!