could someone help me make some weapons for my vr game. I have no idea how to make reload systems, animations or how to make the gun shoot. or is there any good free template that i can use?
you can look into the Lyra project for generic implementation.
the biggest difference between a “first person game” and a “VR game” is a disjoint between look direction and move direction, and “what is and is not an input”
presuming that you have compatible animations and rigs for animations depending mostly on whether the thing animating is an Actor or Pawn/Character:
- for Pawns but more specifically Characters you can use
PlayAnimMontage
(this gives more control including mid animation callbacks, but requires a Pawn or Character which are heavier) - if you need something lighter or are working below Pawn then use
PlayAnimation
- whether you are working in C++ or blueprints primarily: use Blueprints for the animations as it saves fiddling in C++ with changes, and Animations are a lot easier in Blueprints.
a reload system at its core is:
- check value of current ammo vs value of stored ammo
- play animation is stored ammo greater then zero (might play a different one if the ammo is zero)
- adjust both current ammo and stored ammo accordingly
- return animation state to default.
shooting a gun for actor projectiles: (this approach is mostly for “fire and forget” uses but has the overhead of actor count potentially getting out of control)
- have a Projectile object (either object reference, or class reference)
- have a transform point for the projectile to spawn from
- spawn the projectile at that transform (mostly location and rotation, but use the scale from the blueprint)
- if the projectile uses the
ProjectileMotionComponent
then activate it, or go into your own Projectile motion logic. - maybe look into object pooling to save overhead from potentially constantly spawning and destroying actors.
shooting a gun for particle system projectiles: (this approach has a lot lower overhead in term of Actors, but requires more bookkeeping)
- have the particle system instance stored on the object
- have a transform point for the particle system to start from
- perform necessary trace movements for the particle system that make sense
- update the location of each instance of the particle system
- respond to trace results.
Hey there @Panda_legend2011! For templates, I’d recommend the wonder VR expansion plugin:
It doesn’t handle all of it, but it has tons of functionality to help get you started and can work well with the base VR template. You’ll still need to use other resources for the FPS mechanisms. This tutorial series may help with that.
Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.
Thank u so much for the help i really appreciate it.