Log 08: Mounting Work
- Bruce McCormack

- Nov 12, 2023
- 3 min read
The first couple things I wanted to get working about the mount go hand-in-hand: Reducing/refunding Power when the mount is summoned/dismissed, and the menu icon fading out when there isn't enough Power to summon it.
Manipulating the Power cost was easy enough, but the menu reflecting the player's ability to summon the mount proved much trickier than originally predicted. The problem came from the fact that the mount does not exist in the level before it is summoned, and in Unreal you can not access variable information of an actor if it does not exist in the level.
This left me with several possible solutions. The first and easiest would be to just have the cost of the summon hard-coded in and every character it costs the same to summon their mount. This makes the most sense where everyone is basically going to have the same mount. But I was hesitant to do this because 1) hard-coding things makes me feel icky, and 2) I want as many of these systems to be reusable down the line as possible. And I can easily see wanting to have different mount options or customization down the line in a future game if possible, so instead of moving the production cost down the line, I figured I should tackle the problem now while I'm learning anyway.
The next solution that I thought of was just having the mount spawn in with the character and just be invisible and not have any collision. I'm hesitant to do this as I'm not sure how that extra spawning may impact performance, and I can see coding that getting messy. The last option I thought of is to make a data table that would contain all the possible mount options listed with their associated costs, and then I could look up from the table, no matter what/when/where. Of course, that means I need to figure out how to get the row name to search for, which changes the problematic variable from a float to string/name.
There's a trick I learned to get 3D objects to "appear" in the UI, where you spawn an actor with the mesh somewhere outside the world and project a capture of that on to a texture. I bring this up because if I were to do some form of mount customization or choice I would have to do this anyway which would mean I'd have the actor spawned somewhere, at some point, that I could pull information from. This would mean I wouldn't need anything complicated like pre-spawning, or round-about like a data table, just directly get the cost from the mount actor and put it in the same place I would eventually put character selection, then assign some variables during level map loading and there we have it. But that means I can't do this until I make some form of character selection which won't be until later. Meaning I'll have to swallow my pride and stick with hard-coding the mount cost into the playable character for now.
While working on the mount, I realized that the power attacks weren't depleting the player's Power, so that was a quick fix.
This just left things like attacking or dodging while on the mount. I decided that without animations to finish these things up, it wasn't worth working on at this time. It will also give me something to look forward to / break up the monotony when I do get to creating or buying animations.



Comments