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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Cast to character always failing

hi everyone I am trying to cast to my "player character" to get a variable called "has enough currency" for a shop I am making but the cast to player character always and I mean always fails and I can't understand why.

screen shot 1 is of the cast to player character node screenshot 1: ![alt text][1]

screen shot 2 is of the event tick node checking if the player has enough currency or not screenshot 2: ![alt text][2]

screenshot 3 is of what happens when I press the button screenshot 3: ![alt text][3]

thank you for reading and in advance for all help I really will appreciate it [1]: /storage/temp/241432-screenshot-3.png [2]: /storage/temp/241433-screenshot-1.png [3]: /storage/temp/241434-screenshot-2.png

Product Version: UE 4.19
Tags:
screenshot-3.png (253.7 kB)
screenshot-1.png (320.0 kB)
screenshot-2.png (129.8 kB)
more ▼

asked May 18 '18 at 10:51 AM in Using UE4

avatar image

Chad_kroeger2005
27 1 5 11

avatar image Fritte1337 May 18 '18 at 11:01 AM

Are you sure. that your Character is from class Player_character? Could be that there is the wrong pawn in your scene.

That would explain why the cast always fails.

Bregards, Erik

avatar image Chad_kroeger2005 May 18 '18 at 11:03 AM

yes I am 100 % sure

avatar image Chad_kroeger2005 May 18 '18 at 11:04 AM

also I forgot to mention that the cast to works fine in other widgets such as my "HUD" widget to display the currency

avatar image Chad_kroeger2005 May 18 '18 at 11:08 AM

never mind thank you so much I found the answer thanks to you thank you!!!!!!

avatar image Chad_kroeger2005 May 18 '18 at 11:18 AM

1 other question: how would I spawn it in the world once the player has bought it?? (I'm talking about the rocket launcher)

avatar image mightyenigma May 18 '18 at 05:46 PM

I may be misunderstanding your question. You know how to spawn things in general right? Spawn Actor of Class node? That takes in a Location parameter that tells it where the new actor should appear in the world.

avatar image Chad_kroeger2005 May 18 '18 at 09:49 PM

yes but how do I do that??

avatar image Chad_kroeger2005 May 18 '18 at 09:49 PM

do you mean with the transform part of the node??

avatar image Nebula Games Inc May 18 '18 at 09:53 PM

For location use whatever you like, either a hardcoded location or a reference to another actor's location.

alt text

capture.jpg (66.0 kB)
avatar image Chad_kroeger2005 May 18 '18 at 09:57 PM

ok thank you

avatar image Chad_kroeger2005 May 18 '18 at 10:04 PM

for the casting to the spawner (which is an actor) what do I use for the object??

avatar image Nebula Games Inc May 18 '18 at 10:06 PM

What do you mean? This is a "Spawn Actor From Class" node, there is no "casting" to the spawner??

avatar image Chad_kroeger2005 May 18 '18 at 10:07 PM

no I have a spawner in the game and I am casting to it to get the actor's location

avatar image Nebula Games Inc May 18 '18 at 10:16 PM

You would have to use something like "Get All Actors Of Class" which will return an array of all spawners located in the level, so if you have multiple this will be an issue. If you are doing this within a level BP you can easily create a reference to any actor including your spawner by selecting it in the viewport and opening the level BP, right clicking in the event graph and search for "create reference to selected actors". But you need to get a reference to the spawner somehow to be able to get it's location.

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

1 answer: sort voted first

Looking at the blueprint, i see nothing wrong with that. The issue has to be somewhere else. Are you 100% sure that's the exact class for the current player? Maybe you're using a different one (like a stock 3rd person one, or another class you made besides Player_character). One way to check would be to do this :

alt text

See what name prints, and thats the class it's calling. If it's "Player_character" then there's a bigger problem lol

more ▼

answered May 18 '18 at 10:26 PM

avatar image

AJ-Cixelsyd
56 2 4 9

avatar image Chad_kroeger2005 May 18 '18 at 10:27 PM

I already fixed it last night after someone else commented but thanks anyway for your help

avatar image AJ-Cixelsyd May 19 '18 at 12:53 AM

Was that the issue? You should edit your post with the solution for the next person. Glad you got it working though =]

(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