Detect overlap of component from different actor

Hello!

I’m trying to make a Spin the wheel type game but i’m having some trouble.
I got the animation on the wheel working. I made Component collision boxes to help me detect which color of the wheel the arrow lands on.

The arrow is an actor and has the shape of a cone. i want the cone to detect which collison box its overlapping so i can use this information to display the proper question.

The problem i’m having is that i can’t seem to figure out how to detect the different Collision boxes. I’m also unsure if i should do the detection in the Wheel blueprint or Arrow blueprint.

Any help would be appreciated!

I,m interested in reading the rotation, this could get me a more precise result. I will try this out!

You use delegates (in blueprint know as event dispachers)

https://docs.unrealengine.com/en-us/Engine/Blueprints/UserGuide/EventDispatcher

And both actor and shape component have delegate for overlaps.

You can also get all overlaping actors in any moment:

But i got better idea for you :slight_smile: Why instead of using collision system, why not just read rotation of the wheel? Normalize rotation, take pitch (or wherever axis you align with whell). + 180, Then divide it by 360, Frac it, multiply by numebr of avable option, Floor it and oyu can also cast it to int and then you can use switch to proper programing

Could you be so kind to show me how you would do this with a screen shot? i can’t get it to work.

So i have tried to follow the instructions provided but it won’t seem to work. The results don’t seem to be consistent. Any help?

ah sry frac is actully is not needed, i live there when i was trying compose proper calculation for you, but it should not effect final result. What is not consistent in it?

The results from the equation don’t seem to line up with the rotation. I have added to screen shots where the result is 4, but it does not match with the where the rotation stopped.

This is related to this one, right?


Have a look at this approach.

Behold the Wobbly Wheel of Misfortune

Child Actor holds onto an actor that has a static mesh (no collision) and a sphere overlap set to blocking. You can use a box collision for this, I needed to make this quick. Just ensure there are no gaps between collision volumes.

The timeline affects how quickly the rotating component spins the whole thing, It speeds up first to max (random) speed and then spins down following the curves. The curves look like this:

The first one is a timeline Event which interrupts the spin-up phase and switches to spin-down phase. This objects also spawns a pin (just an actor with a cone) which is used to line trace to see if there’s a prize object in the way. If it finds something, it destroys it.

The end result:

Image from Gyazo

The whole thing is initiated by calling SpinUp {spindown-F} event.

Hope it helps. Any questions? Do tell.

Thank you for your answer, i think this is the way to go about this! I’m having a couple problems. The wheel spins on its own and never stops spinning… I tried to start the script with a OnClick event but the click does not register.
I don’t understand how u made the pin. Is it a different actor? If so i don’t know how you would use it like you did.

Thanks!

The wheel spins on its own and never
stops spinning.

Select the Rotating Movement Component and set its rotation rate to 0,0,0 - the default is something like 0,0,180 I think.

I don’t understand how u made the pin

Right click the return value of the Spawn Actor node and Promote to Variable. This automates the creation of the reference. The Pin actor is just an actor with static mesh set to cone (rotated so it faces sideways rather than up - or whatever the default cone rotation is). Btw, the cone is purely visual so you do not even need to put anything there. The whole thing can be probably contained in a single actor but this way you get extra flexibility for anything extra you want to do in the Pin actor.

I tried to start the script with a
OnClick event but the click does not
register.

How would you like to activate it? With a widget button? By clicking it? The easiest way (just to test it out) is to drag the actor reference from the level to the Level Blueprint and call the event directly from there. You can refactor later one you know precisely how things should work.


If it gives you a headache, I can wrap it up and send a project link so you can take it apart at your leisure.

Thanks for fast answer!
I would like to activate the spinning with a mouse click.

As described above.

Ok i got the click to activate working! Thank you!

Got some new problems tho…
The wheel don’t stop properly, it starts to rotate backwards.
I can’t see the pin spawning in. But a print string confirms that the line trace fires off.

I fixed the rotation spinning backwards. I had accidentally made the spin down value surpass 1.

i found the pin too, it was far off screen so i just moved it to properly hit the wheel.
I want the Child actors to tell which color the Pin points to. Do you have any suggestion on how i should go about this? And i want the wheel to be able to spin multiple times and get the same result right now it destroys the actor so i can only hit “green” once.

The pin was just offscreen so i fixed that. I’m looking for a way for the actors to tell me which color the Pin is pointing at. And i would also like if the wheel could be spun multiple times and get the same result, right now the Pin destroys the actor.

All information regarding the field/object the pin is pointing at should be contained in the actor embedded in Child Actor component - see my 1st pic - there’s eight of them; think of them as slots for any actor you want to insert - these actors are then automatically instantiated (and registered) as soon as the parent (wheel) is spawned. It also provides you with direct object references so you do not need to it manually.

You can place any variables and methods in those actors and retrieve them when the trace hits them. This makes this system modular since you can feed the Child Actor component whatever you want.

In your case, instead of destroying the actor, cast it to the object type the Child Actor component is holding onto. This will give you access to its data.

What I’d do to make it look and work better, I’d make the Child Actors fields. Think of a slice of cake with a cherry on top where the cherry is the prize.


Talking about cake and cherries because I’m assuming I know what you’re trying to accomplish. Your vision may differ from mine. I was thinking of wheel of fortune one sees on TV.


Now, if you need 8 fields you can do the distribution manually. Make slices and rotate them towards the middle to create fields.

If you need a variable number of fields distributed evenly then you’d need something a bit more grown-up. I have a piece of BP spaghetti for circumferential distribution somewhere if you’re interested.

And i would also like if the wheel
could be spun multiple times and get
the same result,

It can already be spun multiple times, if you want to get the same result at all times, just remove the random factor and give it the same SpinRNG.

right now the Pin
destroys the actor.

Getting info from the field to the pin would look like this:

Image from Gyazo

My vision is for the wheel to spin, and depending on where the pin lands chose a color wich will the prompt a question to appear. i think this will be possible using your method. I’m gonna try right now and see if i can get it working!

OK, i think i need some more help.

I made separate child actors for each of my spheres and placed them over the corresponding color.

inside the child actors I want to set an integer based on with color the pin points at. I want to the integer later in a separate blueprint.

I have mad an card animation that starts when the wheels tops. I want to set the material of the card to match which color the wheel stops on. I’m trying to do it with a switch on int.

After the card is displayed i want the whole process to be repeatable again.