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"

How to change what actor spawns from a blueprint?

So I’m trying to setup a basic inventory system. Originally I had it so that items that were able to be acquired could be clicked on, then the actor would be destroyed and all the coding for what the item did was in my character blueprint.

I couldn’t get a functioning inventory to work well like this so I watched/read a few tutorials and changed the system. Now I have an actor named “BaseItem” that is essentially an item that can be acquired. When it is clicked on the actor is destroyed like the older method only if the player character has enough room in their inventory. I’m able to recall anything that’s picked up and the system works fine.

My only hang up is that now the only item that works with the inventory system is that BaseItem actor. So instead of duplicating that blueprint a ton and adding a bunch of stuff to my existing blueprints I thought about something: can I make the baseitem blueprint have a variable that is set to instance editable and depending on whatever the variable is the blueprint calls another actor and that is the actor that spawns?

Basically right now the only thing you can pick up in the game right now are a few guns, a flashlight, and some medkits. I was trying to use eventbeginplay in the baseitem blueprint to establish what actor is actually spawned but haven’t had any luck. Was just wondering if someone’s done something like this or if there is a way to use the baseitem actor as a vessel to spawn any one of my items.

PS - I tried setting my variable in the baseitem blueprint to an actor and use that to get that actors components so I could assign the static mesh to the mesh of baseitem but I’m going no where.

Thanks.

Product Version: UE 4.22
Tags:
more ▼

asked Jun 01 '19 at 05:30 AM in Blueprint Scripting

avatar image

MoPhilli
1

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

1 answer: sort voted first

I think what you are missing from the tutorials you watched about creating a "BaseItem" (and it evens alludes to this by the name) is the parenting aspect. You can create child blueprints based off the "BaseItem" and change just about anything you like within the child. So the parent can hold common functions and variables, the children can then modify things like the mesh, the variable values and can even add unique implementation/functions not found in the parent. If you want a detailed explanation of parenting check out video #15 in the link below. Video #16 is a continuation of parenting but I take the principles discussed in the prior video and show you how to do it within Unreal Engine.

https://www.youtube.com/playlist?list=PLyu-W38DvZhqByAoeva1jewB5s78zQHIy

more ▼

answered Jun 01 '19 at 01:50 PM

avatar image

Nebula Games Inc
5.4k 28 9 15

(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