x

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"

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.

![alt text][1]

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! [1]: /storage/temp/256018-view.png

Product Version: UE 4.17
Tags:
view.png (950.6 kB)
more ▼

asked Oct 08 '18 at 07:21 PM in Blueprint Scripting

avatar image

Betag
3 1 2

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

5 answers: sort voted first

This is related to this one, right?

https://answers.unrealengine.com/questions/835332/spin-the-wheel-type-game.html


Have a look at this approach.

Behold the Wobbly Wheel of Misfortune

alt text

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.

alt text

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:

alt text

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.

graph.png (503.5 kB)
tl.png (67.0 kB)
more ▼

answered Oct 11 '18 at 12:07 PM

avatar image

Everynone
10.2k 66 20 37

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

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:

http://api.unrealengine.com/INT/BlueprintAPI/Collision/GetOverlappingActors/

But i got better idea for you :) 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

more ▼

answered Oct 08 '18 at 08:34 PM

avatar image

Shadowriver
31.3k 911 152 1065

avatar image Betag Oct 08 '18 at 08:49 PM

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

avatar image Betag Oct 08 '18 at 09:16 PM

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

avatar image Betag Oct 10 '18 at 10:04 PM

alt text 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?

uten-navn-2.png (102.1 kB)
avatar image Shadowriver Oct 11 '18 at 12:28 AM

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?

avatar image Betag Oct 11 '18 at 10:01 AM

![alt text][1]

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. [1]: /storage/temp/256234-uten-navn-3.png

uten-navn-1.png (331.2 kB)
uten-navn-3.png (334.0 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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!

more ▼

answered Oct 11 '18 at 09:00 PM

avatar image

Betag
3 1 2

avatar image Everynone Oct 11 '18 at 09:09 PM

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.

avatar image Betag Oct 11 '18 at 09:14 PM

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

avatar image Everynone Oct 11 '18 at 09:23 PM

As described above.

alt text

capture.png (47.6 kB)
avatar image Betag Oct 11 '18 at 09:44 PM

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.

avatar image Betag Oct 11 '18 at 10:12 PM

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

avatar image Betag Oct 12 '18 at 11:35 AM

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.

avatar image Betag Oct 11 '18 at 11:09 PM

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.

avatar image Everynone Oct 12 '18 at 06:52 AM

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.

avatar image Everynone Oct 12 '18 at 07:07 AM

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:

alt text

Image from Gyazo

capture.png (114.6 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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!

more ▼

answered Oct 12 '18 at 12:13 PM

avatar image

Betag
3 1 2

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

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. alt text 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. alt text After the card is displayed i want the whole process to be repeatable again.

1.png (388.1 kB)
2.png (71.7 kB)
more ▼

answered Oct 12 '18 at 10:29 PM

avatar image

Betag
3 1 2

avatar image Everynone Oct 12 '18 at 11:40 PM

I don't understand what you're trying to do. You're binding a delegate on Tick? There should be no need for that, ever.

Each actor has an int indicating which colour it is, right? When the wheel stops, read the value from the actor hit, cast to the Player and fire a Custom Event with an int as an attribute.

I want to set the material of the card to match which color the wheel stops on.

When it comes to Switch on Int, it will probably work ok (just lots of wires). It would work better with a Select node and best with an int | color map, which would look like this:

alt text


To be perfectly honest, you can just have each Child Actor store a color variable rather than int and read that if all you need is to set material colour. Switch on int would only makes sense if you needed to execute something unique for every card. It works, sure, but it's unwieldy in the long run.

But again, I might have misunderstood you.

capture.png (116.3 kB)
avatar image Betag 4 days ago

I got everything working in the editor now. The wheel spins and picks a card based on the color it stops on!

However, when i try to package the game it falls apart. The wheel spins just fine but my HUD and any functions after the wheel spin dont trigger. Here is the log. alt text

uten-navn-2.png (53.5 kB)
avatar image Everynone 4 days ago

Can you show how and where (which blueprint) is responsible for spawning and storing the reference to the Pin object?

The cone invalid transform is weird, is XY or Z scale set to 0 by any chance?

Is the map that you're using set as the default map?

avatar image Betag 3 days ago

Here is the blueprint. The scale of the cone was 0 that's fixed now. The problem persists tho

alt text alt text

uten-navn-1.png (101.7 kB)
uten-navn-3.png (133.5 kB)
avatar image Everynone 3 days ago

You're accessing Pin Var before you spawn it. It means there's no way to obtain the location necessary to actually spawn the object :) That's an uninitialised pointer, a potentially dangerous entity.

Just Get Actor Location (self). - Have a look at the bottom left corner of the 2nd screenshot I posted.

avatar image Betag 3 days ago

ok no warnings now! But the game still differs from the editor. I added screenshots where u can see that there is no hud and the animation i'm triggering with the wheel blueprint don't appear.. i still get this warning tho. alt text

alt text alt text

uten-navn-5.png (10.4 kB)
uten-navn-4.png (639.5 kB)
uten-navn-6.png (1.9 MB)
avatar image Everynone 3 days ago

It's nearly impossible for me to deduct what can go wrong as I do not know how the rest of the code looks like. I do not even know what your animations are...

When it comes to the cook error - I'm no expert on this. Ensure the game mode is overridden properly in the Project Settings > Maps & Modes and in the World Settings for the map you're using.

(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