How to avoid overlapping between pickups?

Do a box trace toward the random location from a point a few units above it. If it hits, check if the hit actor is a Coin.

To be honest, I’m new to this stuff. I searched on Google about this “Box Trace” but no good tutorial. I did this (shown in pic) but its not working. I know I did something or everything wrong. Can you please temme how to correct it? And I also don’t know about “Object Type”. It was giving me an error so I just stretch the node and there was only this arrey option.

When looking at your blueprint, I see a few problems.
When doing a box trace, you need to do it from above the random point. So add some value to Z axis and use this as start point. Next subtract a few units from Z axis and use this as End
Then you need non-zero Half-Size. Ideally this should be half the dimensions of your coin’s hit volume. Orientation should be same as the rotation of your about-to-be placed coin.

You also need to make use of the ‘Out Hit’ output pin. It is a struct of many important info about the trace. It will tell you which actor hit by the trace. Use this to see if the trace hit a Coin or something else. You will need to break the struct to use these additional info

However I do fell that you need to understand a few things about Blueprints (especially Casting, BP classes, objects…). Please go through the youtube tutorial series about Blueprints, if you haven’t already.

I wish I could show a blueprint, but unfortunately I wont be able to do that - I don’t have a PC with UE4 with me

okay. I watched all 9 videos and learned something new. But there was no information about my this problem. :frowning:

I set all XYZ +50 and -50 as show in pic. And it’s not working. And I don’t know how to get “Half Size” and how to use “Out Hit” node. Can you please help me further?

You can take a look here: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums
I did the same thing as he did. But I just don’t want overlapping.

Is there any simple way where I can check whether at location generated by “Random Point in Bounding Box” coin is present or not?

Trace is the simplest solution. If its not working, change ‘Draw Debug Type’ (on Trace node). This will show you exactly how the trace is done.

This should help you:
https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html
https://docs.unrealengine.com/latest/INT/BlueprintAPI/Collision/BoxTracebyChannel/index.html

And this is how you break the Out Hit:

Okay. I selected “Persistent” mode. And now I know how it looks like. But now please understand what I did.

  1. Generate a Random location using “Random Point in Boundary Box”.

  2. +20 for Start and -20 for End along all XYZ axis.

  3. Manually entered the half size i.e. 20 along all axis.

  4. Selected Orientation as my coin is rotating.

And then I got the screen as shown below (Pic 2). But it always return false. Just forget the “Out Hit” for a moment. If there is something already present at that specified location then it should return “True”. But it is always returns false.

And since I’m doing this in a loop (4 times) there are more than 4 “Trace Boxes”.

Ok. I did little mistake in connected nodes. it shows true but only in starting. And these “Trace” box appears only for first ramp as show in pic.

P.S. Please read this and previous comment as well. :slight_smile:

I have two function which randomaly calls Blocker or Coins. I’m using box trace in “Spawn Coins” function.
Even when first ramp is “Blocker”, box trace always starts from first ramp. Since it is working for first ramp only, that’s why I’m not getting my desired result. Now can you please help me where I’m doing mistake?

Edit: Since I’m calling “Spawn Coins” from Construction Script. Might it be a problem here? Since it can spawn coins it should also generate “Trace Box”
Waiting for your reply.

At first look, I think this might be the problem. Your trace start and trace ends are a bit off. Trace start should be 20 units above the random point and trace end should be 5 points below the random point.

ie To get trace start, you should add 20 to the Z axis of random point and to get the end point, subtract 5 from the Z axis of random point. This will make sure the trace is vertical. So do not add anything to X or Y axes.

Unfortunately my Dev PC is suffering from hardware issues. Otherwise I could have shown you the blueprint itself. I hope to get a replacement tomorrow. In that case I will post a screenshot.

Another important thing:

Your SpawnCoin function uses the variable CoinArea to decide where to spawn the coin. From what I can see you have seperate Box volumes for each Ramp. But your function seems to always spawn inside whatever volume is pointed at by ‘CoinArea’. I think you need to change the Volume pointed at by ‘CoinArea’ to spawn inside another volume.

I did as you said, 20 and -5 to Z axes. But no progress.

I have 3 ramps.

  1. Normal Ramp.
  2. Normal Ramp + Upper Ramp
  3. Normal Ramp + Bridge

I created Blueprint for “Normal Ramp” and then used it to create other two ramps. Other two ramps doesn’t contain any “Coin Area”, just added additional ramp and everything else is inherited from “Normal Ramp” blueprint.

Normal ramp randomaly spawn either a blocker or coins, when it spawn coins it should do “Box Trace” but it is also doing box trace for blocker as well.

In simple words, it is “Box Tracing” only for first ramp, doesn’t matter it spawn Blocker or Coins.

And I’m uploading my “Coin Area” pic as well. It is just a simple line. I hope this screenshot might help you to understand and can you just edit my above screenshots in MS Paint and just draw box and text box to help me?

Can you upload images of SpawnCoin and SpawnBlocker functions ?

Here:

41987-unreal2.png

I could not see anything wrong.

Just to be clear, are you saying that the engine is doing box trace when it is spawning a blocker? Because I don’t see how that is possible. Your SpawnBlocker function contains no tracing.

Now we should make sure the code is going exactly like you planned. Add some print string nodes at the start of both functions ‘SpawnCoin’ and ‘SpawnBlocker’ to identify which function gets called and in what order.

Also how did you find out that a box trace was done when a blocker was spawned??

Ok. I just added “Print String” just after “Spawn Coins” & “Spawn Blocker” node. And result is confusing :frowning:

Can you upload your project file somewhere so that I can take a look? Also specify the engine version

Project size is ~800MB. It will take me many hours to upload this. And also sometimes net disconnected. :frowning: It is not possible. :frowning:

I’m trying to debug my project but no success. I have just one main ques.
Whenever I call “Spawn Coins” I do box trace then why this function works for first tile only? You have my “Construction Script” & “Spawn Coins” function blueprint and also screenshot. Do you have any idea?

Take a look at this. I called just 2 tiles. And there are 8 Box Trace inplace of 4.
4 per tile. Do you think that relative location function is doing something wrong here for box tracing?

I m printing “Random Location” in the starting of “Spawn Coin” function. And now I’m calling only one tile. And its printing two times. Sometimes 1, sometimes 3 times. But mostly 2 times. Look at the screenshots.

And will you please take a look at this video (#4)?

I did exactly the same. I can’t upload my project because of huge size (800 MB) instead you can look at this video. Please.

I know I won’t call coins randomly at the end of this project. But I want to learn right now. Later, I will thinking about publishing a game.

Solution 3
Snap To Grid function. It helped a lot in my case.
I think it may be the most efficient and simple solution for your case as well