top of page
Writer's pictureHolly Boyle

Equipping Weapons & Collisions

This week, our group began actual development of our game. We started by setting up a shared Google Drive folder for the project. Josh then created a blank VR project in Unreal Engine, and added some locomotion mechanics. This was uploaded to the drive as a base version of the project that we would both use for whatever features we would each develop.

 

Weapons


The first feature of the game I started working on was the weapon mechanics. Our plan is for the player to be able to pick up various melee weapons they find in each level, like swords, spears, hammers etc.


To start with I just modified the existing functionality for picking up objects in the base Unreal project. This was simple enough to do, only involving adding an interface to a sword blueprint and creating a scene component in the motion controller to attach the sword to.



For a first-version this worked surprisingly well, and even allowed for collision with other physics objects. After experimenting for a while however, a few issues showed up around collision.


The main issue was that, since the motion controller actors moved 1-to-1 with the controller tracking in the real world, they could move through other objects in the world. This wasn't so much a problem on its own, but since any objects that are picked up are being attached to the motion controller actors, they would now clip through objects as well.


This could potentially be quite immersion-breaking, and also lead to problems like attacking through walls or losing a weapon after dropping it out-of-bounds.


I wanted to see if I could find another approach to picking up objects that would still allow them to collide with the world properly. I did some research and eventually learnt about the "Physics Handle" component.


This component allows the setting of a "target" location / rotation for a component, and tries to move it to that location while handling physics and collisions. Instead of attaching the weapon component directly to a scene component in the motion controller, I could use the scene component as the target for the weapon to follow.


After some work, I ended up with the following result:



The sword moves with the motion controller, up until it is blocked by a static object.

While this does fix the previous issues, it also comes with its own disadvantages.


The most obvious is how the sword "detaches" from the player's hand when colliding with an object. This is immersion-breaking in its own way, and might make the player feel like they have less control of their weapon.


A possible solution would be to apply the same approach to the hands themselves rather than whatever weapon is picked up, which would be less immersion-breaking visually, but might feel less responsive to the player's movement. It would also then become slightly difficult for the player to see exactly where their controller tracking is in the game-world.


There could be some advantages to moving away from 1-to-1 tracking though, such as simulating weight for larger swords / hammers etc. causing the player's hands to move more slowly. It could also prevent the player simply shaking a weapon in front of themselves to defeat enemies.


Regardless, I spent some additional time experimenting with Unreal's Physics constraint components to see if I could find any way to improve the collision for held objects. I put together some blueprints to make it easier to test quick adjustments to the constraint variables.



So far, I haven't been able to get much better results, and seeing how much time it's been taking I feel like I might have to come back to this at a later stage. There are a lot of other features to start work on and I don't have a clear idea how long those will take, so for now we're sticking with the rough version we have so far.


Spear Weapon


Another weapon we had decided to have in the game was a spear. The idea for it was to give the player a longer reach for attacking, at the cost of requiring both hands to get the most damage out of it.


While it seemed a simple enough idea at first, figuring out the best way to implement a two-handed weapon ended up being a bit of a challenge. I had to do some research into how two-handed objects were typically handled in other VR games, such as the spear in Blade & Sorcery or even just two-handed guns in shooter games.


The example in Blade & Sorcery seemed like it would be far too difficult to translate to our own game, seeing as it relies on physics for much more of its controls. I ended up experimenting with a simpler system, having the spear follow the position of the first hand to grab it, and trying to face its rotation towards the second hand when it is close enough.


The result is a bit buggy and hard to use effectively. I'll have to continue looking into improving it or using a different method.


 

Switching to 4.25


In the middle of the week we learned that there would be issues with packaging our project to our target platform, the Oculus Quest, if we continued using version 4.26 of Unreal. Since things were very early on in development, we decided to make the switch now to version 4.25. This was relatively easy, although it did take up some of the week's development time to set up all of the blueprints we had made again.


Setting up Source Control


One of the better developments this week was figuring out a better solution for source-control. As part of our course we were taught how to set up and manage a repository on Github for our project. This now allows us all to work on the same source code at once, rather than having to swap different versions of the project between ourselves constantly. I'm extremely happy with how much more efficient this will make our workflow, as in the past collaborating on the same Unreal project is something I've found very frustrating.

 

Goals For Next Week


For next week, I'm going to continue working on the weapons system, and hopefully get some basic swinging and hit detection working on a target dummy. Additionally I'd like to get started on figuring out an implementation for two-handed weapons.

7 views0 comments

Recent Posts

See All

Comments


bottom of page