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"

Many questions about blueprints

Hi, first post here! Have been using this forum a lot, but these questions I couldnt find anywhere so I guess I need to make a post now =)

I am making my first attempt on a real game project, a memory game with 3x4 cards.These are spawned through looping (I only have one card_BP made, and I spawn 12 instances of it when the game starts). I want to be able to click a card to flip it around and maybe highlight it when hovered over.

1: So, I made a OnClicked node. How do I get a reference to the correct card? I mean, there are 12. Do I just reference the original card_BP?

2: What would be the optimal way to spawn these on game start? I have made a loop that spawns 12 and stores the name of each one in an array. I used some math to make each card get its position.

3: I want to highlight the one hovered over. I am thinking maybe some edge detection is in order to highlight the outline of the one hovered over. How would I go about this?

4: They need to be randomized/shuffled on each new game. Maybe they could just swap textures, whichever is easier. They should also be "paired", by that I mean there should be 6 pairs where each pair has identical texture.

These are the most pressing questions I have on the process of making my game, but I'm sure I'll have more questions later =)

Thanks a lot =)

Product Version: UE 4.12
Tags:
more ▼

asked Sep 14 '16 at 06:10 PM in Blueprint Scripting

avatar image

danielodland
1 1 3

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

2 answers: sort voted first
  1. If the OnClicked node is part of Card_BP you can just use the SELF node. All actions within this blueprint will affect the current instance automatically.

  2. Sounds good to me

  3. Search for 'linetracing' or 'raycasts'. Here you can find documentation: https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/

Especially this one:

alt text

  1. You could use this macro to get a random element from your array each time when you spawn your cards: https://forums.unrealengine.com/showthread.php?73512-ADD-Get-Array-Random-element

more ▼

answered Sep 14 '16 at 06:26 PM

avatar image

spyro
1.7k 106 117 233

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

1) If the OnClicked node is part of Card_BP you can just use the SELF node. All actions within this blueprint will affect the current instance automatically.

2) Sounds good to me

3) Search for 'linetracing' or 'raycasts'. Here you can find documentation: https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/

Especially this one:

alt text

4) You could use this macro to get a random element from your array each time when you spawn your cards: https://forums.unrealengine.com/showthread.php?73512-ADD-Get-Array-Random-element

more ▼

answered Sep 14 '16 at 06:27 PM

avatar image

spyro
1.7k 106 117 233

avatar image danielodland Sep 15 '16 at 08:19 AM

Hey! Thanks for your reply.

I have just gotten around to trying the first problem. The solution works, any card I click now turns 180 degrees. However, I need them to turn back when I click them again. Any idea how to do this? I tried this: alt text

Also, I am just now realizing the game logic will need to know which two cards are identical. Like I said earlier, there will be 6 pairs of cards where each pair is identical and the objective of the game is to find the pairs. But the game needs to know which cards "belong to each other". So, how can I do this? Do the cards need to be tagged somehow on spawntime? Anyone have some ideas for this?

turn180.png (155.8 kB)
avatar image spyro Sep 18 '16 at 05:47 PM

I would suggest to just 'link' two cards together (just save a reference to the 'partner card' as a blueprint variable when spawning them and then check if the other card == 'partner card'. You also could create a simple function like

isPartnerCard(otherCard):boolean

where you check if the image of the current blueprint instance (self) == the image of 'other card' and then react to it.

(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