Loading...
16
Game
Hensen Hopper
5 months ago

I don't know how well you can see it in this video, but I've coded a dashing mechanic for Hensen Hopper! I plan to have dashing consume a "dash charge," a kind of ammo you can get as you play in the form of enemy drops.


The way I've written this actually makes use of the sine function! Whenever the player presses shift (keyboard) or X (x-box controller), a timer counting at 10x real-time is started and Hensen's movement speed is increased with respect to the sine of the timer's value. The timer ends at Pi seconds.

code_kz9bgdkieq.png

I chose to do it this way because using the sine function as a multiplier for the increase in movement speed has the effect of blending the dash in smoothly so long as my timer starts at 0 and is stopped at Pi (because sine 0 and sine Pi both equal 0 and sine anything between those two values is a positive number <= 1). In order to modify the duration of the dash or the speed of the dash, I can simply multiply Time.deltaTime when incrementing the timer or multiply the Mathf.Sin() call respectively.

I then capped the movement speed increase to a value I can modify from the inspector which has the effect of making it so increasing the multiplier on the Sin call beyond that speed increase cap, rather than increasing the movement speed increase during the dash, increases what you could call the abruptness of the dash.

Much like everything else in my PlayerController script, the dash is triggered in the Update method based on the player's input read from the InputManager and the HandleDash method only modifies values related to Hensen's movement, which are used in FixedUpdate where the actual movement of the character in the scene is performed.

code_ymwwk7nnyn.png

One thing I'm thinking about adding to this is actual variables for the dash duration and dash abruptness (aka the multiplier on the Sin call) that I can modify from the inspector. The dash abruptness is fine, I'd just need to do a bit of planning for dash duration. I know there is a way to normalize the duration into seconds, I just need to work out algebraically what the formula is for this and then implement that into my code. I also plan on adding some effects for the dash to make it easier to tell when you're dashing which is an entire other task.

Thanks for reading!



0 comments

Loading...

Next up

I DID end up making the body and elytra both 1 cycle/s and the wings 6 cycles/s. I'm working on a video of the animation itself playing in the Unity editor so you guys can see it properly. I think it turned out well!

Finally working on the sprite for the beetle enemy!!! I need to get off my computer and do some stuff right now but I thought the idea of posting a headless (I haven't done the head yet) beetle screenshot was hilarious so I'm doing that first lmao.

Working on getting the itch page for Hensen Hopper set up which means creating a separate cover image for the game on itch (different aspect ratio there). I want to publish that with first beta build of the game so I DO need to get a move on with it.

Kikkerstein had a great day 1 at LVL UP EXPO!

If you’re in Vegas, come see us on day 2!

I drew a concept sketch of the beetle enemy based on a real-world species called the grapevine beetle. This enemy will NOT fire bullets at the player but instead moves back and forth in front of other enemies blocking your bullets from hitting them.

Happy #WIPWednesday! Are you working on a game? Making some art? Practicing a song? Something else? Tell us in the comments!

I added an animation and sound effect when the player collects the heal-up drop. In the lore, this flower is going to be Hensen's favorite food which is why the sound effect is a crunch like he's bitten into something.

I've gotten the defeat animation for the enemies in this game working! Next thing I need is a good sound to complete the effect. I quite like this animation as-is but I'll probably tweak it post-beta. The first beta should be out by new years day!

This week's Fan Art Friday celebrates #CronosNewDawn

Accept the quest in your quest log to get started.

GJ Pro-Tip: Not sure what to make? Check out the game's Steam page for inspo: https://bit.ly/cronos-steam

OKAY, here's it ACTUALLY finished! Quite happy with how this turned out, actually! I've drawn this sprite in 3 layers, the wings, the elytra, and the body, which will make animating this thing a lot easier when I get onto doing that.