Ammo crate

I am trying to make a weapon crate for my game and I did a pickup that inherent’s from aactor but not really sure how to put the code but I do kown to make a spherecomponet but that’s all I have

Hey there, you need to do a trace on the player to find what objects the player is looking at, if you find a hit and that hit is a pickup object then you call a OnPickedUp function to add ammo and destroy the pickup actor.

how do I trace the player sorry i’m pretty new to this

Check this.

Hi,
I’m not to sure if C++ code is what you need right now. If creating a sphere component is all you can do at this point, you’re definitely lacking some essential basics (at least right now).
Depending on your programming experience there are two options you have right now:

  1. If you’re new to programming in general it would be smart to go with blueprints. You’d be surprised how much you can do in UE4 without using a single line of code! Blueprints are widely considered to be more user friendly, due to their visual scripting and more flexible (you don’t have to constantly reload your solution). If you want to give it a try watch this tutorial [Intro to Blueprints: Blueprint Introduction | 01 | v4.8 Tutorial Series | Unreal Engine - YouTube] to get started.
  2. If you really know your way around in C++ (or object-oriented programming in general) go ahead and try to code everything in C++ but make sure to watch this tutotial [C++ Battery Collector: Introduction | 01 | v4.9 Tutorial Series | Unreal Engine - YouTube] by Epic and try to work along. It will teach you some basics, you’ll need to understand before proceeding.

This decision whether to use C++, blueprints or a combination of both is not final but still essential to make. The smartest way is to try out all workflows and decide which of them suits you best.

Hope I could help you out a little! :wink: