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"

Raising an actor by clicking directly on it and holding mouse button

I have managed, however inelegantly, to create a blueprint that allows me to raise a block (blueprint).

Now if I have one of these blocks I can raise it (and I've done a lower function as well, pretty much the same).

I have two issues:

  1. It doesn't matter where I click on the gameplay screen, the block raises regardless. I only want to raise the block I am clicking on.

  2. If I create a second block, wherever I click on the screen only one block moves, and it still doesn't matter if I click on a block or not.

Here's the construction script: alt text

Here's the Event Graph section for raising the block: alt text

And here's the Raise Ground Function: alt text

What I'd ideally like to do is raise/lower any particular block whilst I'm clicking on it.

As a bonus, my goal is to have 25 of these blocks and when I click on the centre one it raises that one, then raises the surrounding blocks at a slower rate, and the blocks surrounding those raising at an even slower rate. Then I want to use the middle mouse button (or any other) to bring all the blocks surrounding the block clicked on into line whether raised or lowered.

I'm missing something key. Number 1 above is the priority. Still, any assistance would be appreciated.

Atonnis

Product Version: Not Selected
Tags:
problem3.png (38.2 kB)
problem1.png (140.7 kB)
problem2.png (93.4 kB)
more ▼

asked Oct 08 '14 at 06:17 PM in Blueprint Scripting

avatar image

Atonnis
48 11 13 17

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

2 answers: sort voted first

Hey Atonnis-

The setup you have in the "nomousehelddown.png" is actually very close to what you're looking for. By adding a "Get Player Controller" node you can drag off of the return pin to add both the "Set Show Mouse Cursor" and "Set Enable Mouse Over Events" nodes as needed. Below is another image of mostly the same nodes from your image (I did use a Set Relative Location rather than Set Actor Relative Location) plus the nodes for showing the mouse and enabling mouse overlap events in the top right.

alt text

raisingobject.png (311.9 kB)
more ▼

answered Oct 27 '14 at 07:18 PM

avatar image Atonnis Nov 08 '14 at 02:20 AM

OK, daft question, but one I frequently come up against and every time I miss the answer I bang my head on the wall.

You've added a Set Relative Location for the Target being the RaisingActor_C (StaticMesh1) but all I can get is the target being SceneComponent. How did you get it there?

Is it something to do with the fact that I'm generating the objects in the Level Blueprint at the beginning, so it isn't an object listed in the Scene Outliner...so I'm not sure where i'm going - I know it's basic, I know I saw it in a tutorial, but given the number of tutorials I've been through I'm not sure how I'd find that specific requirement. I'll research and give the answer if I find it.

avatar image Atonnis Nov 08 '14 at 02:39 AM

Oh, I should mention that the problem isn't getting to the Set Relative Location stage.

The problem is that I'm not even getting recognition of the mouse being over any of the spawned objects, nor an instance of the object that I put into the project manually.

The rest of my graph is pretty much the same as you've put in, but I never see anything when debugging that shows the MouseIsOver boolean variable ever going to Yes.

avatar image Doug E ♦♦ STAFF Nov 10 '14 at 04:10 PM

Based on the last image you sent of the blueprint that controls the actor, the node that enables mouse over events is missing. If you add a "Get Player Controller" node you can drag off of it to then create both the "Set Show Mouse Cursor" and the "Set Enable Mouse Over Events" node. Wiring them into an event such as begin play or another key press will show the mouse and allow it to register the Actor Begin Cursor Over node which should trigger the mouse over events.

If you post an image of what your actor blueprint looks like it will help determine how to edit it properly.

Cheers

Doug

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

Hey Atonnis-

In your event graph for the raising of the block, you'll need to add a "Get Player Controller" node and wire off of that to a "Set Enable Mouse Over Events". You can then wire the input execution pin into your InputAction node. This will give you the behavior of only affecting the box when the mouse is held down while over it. This should also prevent any other boxes from reacting to the mouse input without the mouse overlapping them.

Cheers

Doug Wilson

more ▼

answered Oct 08 '14 at 06:46 PM

avatar image Atonnis Oct 08 '14 at 08:04 PM

Hi Doug,

Thanks for the answer. Do you mean like this? This didn't have any effect. Am I missing something?

alt text

problem_res1.png (58.7 kB)
avatar image Doug E ♦♦ STAFF Oct 09 '14 at 05:53 PM

Rather than using your InputAction to set Enable Mouse Over Events, try using an Event Beging Play. This will allow for mouse over events from the start of the game. Then use an Actor Begin Cursor Over event to set a bool that checks if the mouse is over the object (and and End Cursor Over to reset when the mouse moves away). Using an Event Tick to first check the bool for if the mouse is over the object and if that is true, do another check if the mouse is held down. This can then be wired into whatever drives the movement of your actor.

avatar image Atonnis Oct 12 '14 at 03:33 AM

OK, I get what you're saying. This is how I built it:

alt text

However when debugging I never see any output from the Event Actor Begin Cursor Over or Event Actor End Cursor Over. It's like it didn't detect the mouse was over the object.

The pressing of the left and right mouse button still set appropriately, and the End Tick is pulsing away, but since it relies on the Mouseoverobject bool that never gets set nothing moves on from there.

I can't help but be feeling a bit stupid now. I know the logic in my head but I just can't get the blueprints to do it. I have to admit I wasn't in favour of using Event Tick at all as from what I understand it relies on clock cycles and can have adverse performance on a game if the CPU is overloaded. Still, I'll go with whatever advice I can get.

problem5.png (116.1 kB)
avatar image Atonnis Oct 12 '14 at 03:34 AM

Oh, just below the Branches coming out from Event Tick the condition bools are Mouseoverobject for the first and Mouse Held Down for the second.

avatar image Doug E ♦♦ STAFF Oct 13 '14 at 02:57 PM

Hey Atonnis-

A Set Show Mouse Cursor node will unlock the mouse from the viewport and still allow it to interact with the scene. This along with the enable mouse over events wired to a Begin Play will let you move the mouse around and click on objects in the level. The Tick event will allow for the game to check each frame is the mouse button is still held down and will give a more fluid animation for the movement.

Check out this setup to help get started:

alt text

mouseclick.png (254.0 kB)
avatar image Atonnis Oct 15 '14 at 12:52 AM

Hi Doug. Thank you for your help.

I have one problem - my game mode is to already have the mouse cursor enabled, but even on changing that I cannot find a way to create the SET Show Mouse Cursor with a target. It doesn't seem to be on the list of available commands.

Any thoughts?

avatar image Doug E ♦♦ STAFF Oct 15 '14 at 01:26 PM

It should appear in your context sensitive menu if you pull off of the return pin from Get Player Controller.

avatar image Atonnis Oct 25 '14 at 09:58 PM

OK, here is now how the layout has been done, and is running. I now have detection of mouse over the object, but the left-click of the mouse is not detected so nothing ever moves.

alt text

nomousehelddown.png (144.2 kB)
avatar image Atonnis Oct 26 '14 at 01:22 AM

OK, I've gone one step further with the whole plan, but it doesn't change much.

I have now created the following (yes, it's messy, but I'll tidy it down into functions once I see the debugging lines show me it's all working).

The following is designed to create 9 of the blocks previously referenced (it goes on further to the right creating all 9 blocks. However, I cannot reference any of the generated blocks or interact with them.

In this case, I'm not even receiving a mouse-over event, let alone a mouse-click event. Any idea, please please please. I'm getting so close to getting a core mechanic sorted out and this is now SO frustrating. alt text

build9blocks.png (219.7 kB)
avatar image Atonnis Oct 26 '14 at 01:23 AM

Oh, for reference the last image I posted was from the level blueprint.

(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