Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Make Variable Only Affect One Player

I'm making a game that's going to be multiplayer so, when i pick up a powerup i want the only the character that picks it up to be affected.

Product Version: UE 4.21
more ▼

asked Jan 16 '19 at 11:47 PM in Blueprint Scripting

avatar image

Logz 123
1 1 2

avatar image Evigmae Jan 17 '19 at 03:06 AM

would you even know how to make it affect everyone?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

This is how I personally would approach it.

 When player is overlapping powerup and player is pressing pickup button (optional) {
     Then get reference to who picked up the powerup {
         OnServer: Check if this is valid action by player
         OnServer: Add powerup effect to player
         OnServer: Remove powerup from world.

more ▼

answered Jan 17 '19 at 02:13 PM

avatar image

280 1 8 5

avatar image Logz 123 Jan 17 '19 at 09:13 PM

That's the part I'm stuck on, how would I get a reference to the player who picked it up in Blueprints?

avatar image Weibye Jan 18 '19 at 04:07 PM

You can use collision overlap to find exactly who is "touching" the item. When that happens, OnComponentBeginOverlap is triggered, and it gets information about the other object, in this case the player.

1: Start by adding a sphere collision to your pickupable item.
Adding sphere collision

2: Make sure to enable OnBeginOverlap Events (scroll down in the details panel on the sphere collision.
Enabling OnBeginOverlap Events

3: OtherActor -> Cast to player pawn to make sure it actually is a player pawn (now you have a reference to a specific player pawn), then pass the information on to whatever code that deals with removing the item from the world and applying the powerup effect on the player. Getting the player information

To get the player controller, simply get which controller is possessing this pawn.

1.png (299.3 kB)
2.png (205.9 kB)
3.png (112.8 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question