x

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"

Reducing my lives doesn't work by function or custom event

So when an AI gets to my target location, it calls a function that is on my HUD, I also tried using a custom event - the event and function both says to take 1 life off in my HUD.

In my HUD I made a function: alt text

In my HUD graph I made a custom event: alt text

And I guess this is where it's going wrong; in my targetlocation is where I trigger both the event and function, maybe I am not doing it right ? alt text

Product Version: UE 4.8
Tags:
more ▼

asked Jun 30 '15 at 08:36 AM in Blueprint Scripting

avatar image

Dannyk90
250 35 36 51

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

2 answers: sort voted first

Hi,

where is your Lives var stored? If this is per player variable, then i recommend store it in player controller bluprint, since there should be only 1 player controller per player. Then in your HUD function "Remove a Life" you can do this:

  1. Get Player Controller (at needed index, 0 will be current player even for multiplayer games)

  2. cast it to you custom player controller (if you have it)

  3. get access to Lives Var of that controller, just draw out cord from player controller reference, disable context sensetivity and write "Get Lives Var".

more ▼

answered Jun 30 '15 at 10:35 AM

avatar image

happyhorror
576 53 46 72

avatar image Dannyk90 Jun 30 '15 at 06:32 PM

My lives var is in my HUD widget blueprint. I need all players to share the lives.

avatar image happyhorror Jun 30 '15 at 07:46 PM

seems this is the problem, because every user in multiplayer will have his own HUD widget and his own variable, so try move it to gamestate because seems only one exist per type and game

avatar image zamy Jul 01 '15 at 11:28 AM

yep that value it's more fitted for the gamestate. Anyway, try to print the "HUD ref" value. Can you show where you set it too?

avatar image Dannyk90 Jul 01 '15 at 03:58 PM

move it to gamestate, what is that ?

avatar image happyhorror Jul 02 '15 at 11:31 AM

bluprint based on gamestate class in blurprint folder

avatar image Dannyk90 Jul 02 '15 at 12:15 PM

do you mean the level blueprint ?

avatar image Dannyk90 Jul 04 '15 at 01:18 PM

please can you tell me

avatar image happyhorror Jul 05 '15 at 08:40 PM

GameMode class, for example when you open Third Person Template there's standart blueprint ThirdPersonGameMode and this is exist only as 1 instance per level i think, better place you lives counter here because you can simply get access to current game mode

avatar image Dannyk90 Jul 05 '15 at 09:45 PM

im not sure what you mean by putting lives counter there

avatar image happyhorror Jul 05 '15 at 10:42 PM

you told your counter in HUD blueprint, but every player have his own HUD and probably you can't get reference to client's hud also every player will have his own counter in this way

The idea i trying give you is just a code design following next rules:

* if you need store anything related to whole game and not to every playr, better place would the class that exist only as single instance and accessible simply from everywhere, example values

total player lives (your variable), game pause state wave number and so on

better store all these in GameMode blueprint or level blueprint, here is screenshot of third person template and it's default GameMode blueprint, note that you can create your own blueprint based on GameMode class and assign it as default in project settings

alt text

* if you need to store something related to player better place would the class that is player related, it's PlayerController, example values

player's lives (not unit's, but whole lives for player like in TD games), player's inventory size (for RPG style games), player's level (for RPG and MMO style games)

avatar image Dannyk90 Jul 06 '15 at 07:29 AM

ah so you mean I should store the actual variabls in gamestate and call them from my hud etc

avatar image Dannyk90 Jul 06 '15 at 12:22 PM

YESS IT WORKS, YES :D

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

1- "I will remove a life" gets printed? 2- HUD ref is valid?

more ▼

answered Jun 30 '15 at 09:01 AM

avatar image

zamy
391 17 12 32

avatar image Dannyk90 Jun 30 '15 at 09:34 AM

it is valid, it compiles with a tick, the hud reference is a variable with my hud selected - the hud is where my lives number is.

avatar image zamy Jun 30 '15 at 10:01 AM

If it compiles, it doesn't mean a variable is valid. Anyway, about the question number 1?

avatar image Dannyk90 Jun 30 '15 at 06:20 PM

yes the text does print

(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