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 reference components added at runtime

Hi, I'm working on a infinite runner-like blueprint that adds static mesh components to itself at runtime along a random generated spline. I want to delete the components that are behind the player position therefore I store all the added static mesh components to an array of structs that have a static mesh component reference and its distance along the spline:

alt text

Then every tick i check at what distance along the spline the player is and delete all the meshes that are behind:

alt text

But I always get a Accessed none trying to read propriety Static Mesh_blablabla on the "Set visbility" node. Am i storing the components in a wrong manner? The components are there because I can read the distance and the name of the component. Can anyone tell me if I'm missing something?


Product Version: UE 4.21
20190511-1305.png (299.9 kB)
more ▼

asked May 11 '19 at 11:11 AM in Blueprint Scripting

avatar image

1 1 1

avatar image Everynone May 11 '19 at 11:56 AM

Hard to tell. You delete the mesh but what happens to the struct? Perhaps you end up with a struct array entry with a dangling pointer to the deleted mesh? Does your N index account for that?

When you print it, does it all add up?

avatar image Nebula Games Inc May 11 '19 at 03:14 PM

Check out video #25 and #27 in the link below. They go over how to create references and the "accessed none" error.


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

1 answer: sort voted first

Also, here's a quick alternative since that should be quite performant and suitable for infinite runners. It does not rely on indexing and is event driven. It may not fit with your game design / concept though. I'm gonna leave it here in case you want to experiment:

The player has an overlapping volume behind them:

alt text

And each tile fires onEndOverlap if it collides with the player.

alt text

Image from Gyazo

No casting, no Ticking, no arrays, no indexing.

cap2.png (355.8 kB)
capture.png (216.8 kB)
more ▼

answered May 11 '19 at 12:03 PM

avatar image

15.3k 77 26 64

(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