How do I change through weapons with scroll wheel in a FPS game?

Hey!, I am a beginner with UE4 and I wondered if anyone could help me create a system that allowed my character to scroll through various weapons using the scroll wheel on the mouse.

(this is for a class project demo not a full videogame)
(I am working on version 4.27)

If any more information is needed just let me know and I’ll add my project details as soon as i can ^^

You can read the scroll wheel with this

image

1 Like
  • keep weapons in an array
  • increase / decrease index when scrolling up / down
  • ensure the index wraps into array bounds
  • fetch desired element from the weapons array and store its refernce


Ideally you’d add some kind of actor validation to make is safer.

2 Likes

thank you very much! I will try this as soon as I can ^^!

1 Like

Make list of weapons in some array.
Detect scroll mouse event
read next/previous weapon from array,
destroy old one spawn new one attached to hand bone.

Done.

1 Like