Trace is giving incorrect distance?

Hey all I’m having trouble creating a random room generator and I can’t figurer out this function that will ensure my rooms do not intersect when generated.

It seems the trace function ignores it’s distance for some reason and so it always returns 0 regardless if there were a hit or not. I’m not a math person but I’m sure what I have setup should work, my trace just always returns 0, and I can clearly see it isn’t.

I open a door and a trace goes forward and then left, right incrementing through the array based on what the room’s size should be. If it hits a wall it will set size variables depending on trace distance/tile size so rooms do not overlap. But since the trace always returns 0 it just goes through anyways for some reason.

Yes yes for some reason my room size limit is being set to 0, so the min will always return 0.

  • what’s the value of Room Size Limit (Left)?
  • how about Tile Size?
  • what do you get when you Print Distance directly?
  • can you show the trace debug?

I randomly set the potential room size-L/R at begin play(anywhere between 5-25).

Tile size is just 1000.

If I print distance for the int it is 0, but a float returns .0random numbers

I think what is happening is the trace instantly collides with something in the way which ruins the whole thing I’m guessing the door or something

Edit: Hmm checking in again it seems the float always returns the correct number but the int will always print as 0.

If Distance looks OK, then the issue is with:

  • Tile Size: division ends up with a small number which is then rounded down to 0
  • Room Size Limit: it is not what you think it is at the moment of execution

Remember you can watch values by right-clicking pins:

341017-screenshot-2.png

Or Print EVERYTHING :smiley: