Index variable changing to 0

Good day all,

I have a very interesting problem that I would like to address. I have an ‘call in editor’ event that allows me to return a grid section back to its proper position (just incase i move it while editing). When I only have the ReturnToSlot event and activate it, it resets the grid index to 0.

I debugged it with a straight print from ‘returntoslot’ without the location function. And it gives me the correct index.
I then randomly thought I would debug it with a seperate ‘call in editor’ event (customevent) with a straight print function, and this literally stops the ‘returntoslot’ function from reseting the index.

I am so lost. This is not the only place I use the grid index either, when it is spawn, it uses that index to call other information and works fine.

The GridIndex variable is inherited from a parent actor, but is Set in an event straight after spawn. Like I said, the index is accurate and set UNTIL this happens (minus the random customevent)

The only thing I could possibly recall this to, is if I have exposed the variable to the editor. But this is NOT the case.

I am still learning a lot, and Arrays is a new venture for me. Please advise, until then the ‘custom event’ stays…

It seems possibly that you’re jumbling up editor work with runtime.

Call in editor is one thing, and setting index values on spawn is another, but totally separate thing.

Runtime and editor modes don’t mix, really.

Does this make any sense?

1 Like

I understand that concept,
I have an editor call function on the parent to activate the grid spawn. none are activated at runtime. All is activated with a click of a button in editor. As I want it to be an editor system to make my future editing easier.

So the spawn is, I have a x,y grid system. I input the variables and spawn the size I need.

Spawn is the wrong word maybe?

1 Like

Ok, spawn might be the wrong word :slight_smile:

However, I don’t see anything changing the index variable, can you show more code?

Here is the creation code that also sends the index to the ‘spawned’ actor. This works successfully.

Like I mentioned before. I debugged it all the way to working successfully UNTIL I run that ‘get element’ function that somehow, for some really weird reason, it resets the index variable… very confusing.

And these are the other 2 events that activate on the actor that is ‘created’. These initiate and work when debugged. All information passes to the actors successfuly

But where’s the thing that says ‘GridIndex += 1’?.. :star_struck:

This one?
This is in the parent actor, it creates index and position

1 Like

Yeah, I’m mind boggled.

I just add the ‘custom event’ print at the end of my ‘gridspawned’ event and it just fixes it. It’s like as if the variable needs a reminder of its information…

It works for now, I’m sure I’ll learn something down the track that makes me go ‘ohhh’

1 Like

Yes, sorry, it’s hard for me to get an overview, I’m just seeing bits of code, and not really clear if they are all in the same actor or not…

1 Like

Ok, new thing I found… It resets to 0 when I move it. I think it’s in construct as I deleted a local variable in there from messing around a while back. But this still didn’t fix it.
But I think its in construct… still searching

1 Like

No Worries

Construct can run many times when you move an object :slight_smile:

So… still problem solving… i even turned off run construct while drag, and it still does it…

in runtime, while simulation is going, it doesnt do it…

Well… If i turn instance editable to true, it fixes it…

1 Like

No idea what’s happening there :joy: