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"

Toggle visibility and change character

So I'm trying to setup a way to change character as well as change what they see in the world around them.

By pressing space I've managed to create 2 pawns that you can switch between. What I want to happen as well as that they see different things. So toggle the visibility of certain objects around them.

I tried setting up something in the level blueprint for pressing space but then that takes priority over the switching character mechanic.

I tried making a blueprint which has 'enable input', but that gets ignored if used.

Would anyone know a good setup for this? Maybe I'm just thinking too complex right now. Thanks in advance!

Product Version: UE 4.20
Tags:
more ▼

asked Oct 08 '18 at 08:57 AM in Blueprint Scripting

avatar image

ZippyZillion
1

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

if you want two input events to fire when you press a button you could just disable consume input. this will allow many events to work from the same key press.

personally however your situation sounds to me like a good instance to use a interface. when you press space you call a interface event which will get triggered on every actor that implements the interface. so basically one script to affect all the things. you can even implement the interface in the level bp if you wanted. a major benefit of this approach is you only need a input event in one place which is good practice and makes for easier debugging later.

more ▼

answered Oct 08 '18 at 01:46 PM

avatar image

ThompsonN13
10k 33 8 23

(comments are locked)
10|2000 characters needed characters left

I would recommend moving the input event out of the level blueprint and into the player controller (use the same controller for both types of pawn).

As for choosing which objects are visible to each pawn, I'm not sure the best approach. The first idea is to set a Tag on each object as either "PawnTypeOneCanSee" or "PawnTypeTwoCanSee", and upon Possess event of the pawn class it can GetAllActorsWithTag for the one tag and set Hidden in Game to true on those, and GetAllActorsWithTag for the other tag and set Hidden in Game to false on them.

By using the Possess event then it does this at the point your playercontroller takes control of the other pawn.

But I think if there are a large number of objects to switch the visibility of, then this approach will cause the game to freeze every time you switch pawns, so I'm trying to think of a more efficient way that doesn't require you to set tags and loop through them, like maybe some special way of using materials or actor ownership (OnlyOwnerSee checkbox) or something, but I haven't come up with anything yet.

more ▼

answered Nov 21 '18 at 04:57 PM

avatar image

mightyenigma
3.7k 18 19 20

(comments are locked)
10|2000 characters needed characters left
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