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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How Do I Make My Hammer Rotate To Smash A Nail and Come back to its position?

Hi guys! I'm doing a little project with a hammer as the main character. I want him to smash a nail just by rotating on the Y axis at let say 70 degrees, and then come back at its position when I release the button.! Right now I have this, so it is not much. But I believe I need a lerp somewhere, and a variable to store the start position for the hammer to comeback? I believe if I find out this last bit I could be able to do the "Released". Thanks in advance for the tips! I'll continue to experiment on my side! :) alt text

Product Version: UE 4.19
questionun.png (71.3 kB)
more ▼

asked Dec 31 '18 at 08:40 AM in Blueprint Scripting

avatar image

5 1 2

avatar image YourBoiCasey Jan 09 '19 at 07:44 PM

So I have made some progress (I guess) today. My hammer can now smash in any direction it looks at. But, I have this weird/fast animation going on not sure why (video : https://youtu.be/t1yasn-tO_0 )

alt text

If someone could help me find WHY I can't smash while moving, that would be great!

avatar image Tuerer Jan 09 '19 at 09:03 PM

Something interferes with the movement, as it would seem. Can you show me the final BP as you have it?

And is there something else that influences the hammer position? Something that works all the time on tick or something.

avatar image YourBoiCasey Jan 09 '19 at 09:27 PM

alt textalt text

This is all I have and the BP for the jump, which is the 3third person sample one.

alt text

timelinebp.png (42.9 kB)
camerabp.png (245.4 kB)
mouvementbp.png (198.4 kB)
avatar image YourBoiCasey Jan 09 '19 at 09:59 PM

Just in case it matters, here is the inspector of my hammer.

alt text

inspector.png (15.4 kB)
avatar image Tuerer Jan 09 '19 at 10:15 PM

I'm not entirely sure, but I think the problem might be that you rotate not the Hammer, but the entire blueprint (self in the Set Relative Rotation), so you rotate everything, including the Mesh, from which you take the Rotation, so every moment of time the A in the ease changes, and that shouldn't happen.

Try rotating only the Hammer, not everything at once. alt text

ham.png (34.4 kB)
avatar image YourBoiCasey Jan 09 '19 at 10:39 PM

I don't have Set Relative Rotation, I have Set ACTOR Relative Rotation. Every time I try to link your node "Set Relative Rotation" with my hammer, it goes : "Static Mesh Component Object Reference is not compatible with Actor Reference Object".

I'm really lost here. Maybe I didn't say it before, but my hammer is a character BP. If that can help.

I have thought rotating an object would be easier than this. Daaaaamn.

avatar image Nebula Games Inc Jan 09 '19 at 11:42 PM

Set "relative" rotation means you are going to rotate a component mesh (ie the physical hammer mesh) relative to the parent root component. So you can call your BP "Hammer" but that doesn't mean it is a "hammer". You want to rotate the static mesh component that is the actual hammer. So drag out the mesh component and search for set relative rotation.

avatar image YourBoiCasey Jan 09 '19 at 11:54 PM


Both of you, thank you so much for helping me out. You are amazing. Now, I understand more blueprint than before, thanks to you two!

I will now "close" this thread! :)

avatar image Nebula Games Inc Jan 10 '19 at 12:20 AM

No problem, I didn't really do much, just kinda cherry picked at the end of this rather long help session haha But I am happy it works :)

avatar image Tuerer Jan 10 '19 at 06:48 AM

Glad you reached your goal.

When you create a node in the blueprint, you can select from lots and lots of possible nodes, that's why there's the Content Sensitive option available (a tick box in the right upper corner). When it's enabled and you drag a pin off any node, the list will contain nodes that are compatible with the one you want to connect. E.g., Launch Character only applies to Pawn, you can't use it with a static mesh; or Substring only works with String variables, so if you drag a pin off an Int variable, that Substring node won't be available.

The same with actors and components: even though such things as Set Rotation work virtually the same for actors and components thereof, those actors and components are different types of variables, that's why they use different nodes for similar functions.

So whenever you want to do something with an actor or a component, the best way is to place it into the event graph and drag a pin off it, thus it will be much easier for you to find the node you need.

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

1 answer: sort voted first

I think a Timeline will be perfect for this. Make a Timeline with a curve like this, for instance: alt text

And then just launch the timeline to hit. You can set it to Loop if you like. alt text

curve.png (24.1 kB)
bp.png (64.6 kB)
more ▼

answered Dec 31 '18 at 11:16 AM

avatar image

1.8k 12 7 8

avatar image YourBoiCasey Dec 31 '18 at 06:58 PM

Marvelous! You're right on the spot! Thank you so much!

There is just a small problem : When I click, the hammer position itself in the forward direction even though I'm looking else where. Do you know a node that could help me to use this timeline in any direction? Thanks alot again! :D

avatar image Tuerer Dec 31 '18 at 07:28 PM

It's just an example. Take your hammer's rotation and put it into the A instead of 0,0,0, and change the B accordingly to what will work for you.

avatar image YourBoiCasey Jan 01 '19 at 12:05 AM

Will try that in the next few days. You da master!

avatar image YourBoiCasey Jan 05 '19 at 09:43 PM

Hi there! I tried what you said before Tuerer and sadly it didn't work. Or maybe I just made a mistake. The hammer stills hits in ONE direction only (the forward direction) even if he turns 90 degrees.

Maybe I need a variable that says "you're looking this way, so you hit in this direction"?

avatar image Tuerer Jan 05 '19 at 10:29 PM

Hey. Actually, that's what the Relative Rotation is for, it's supposed to rotate the hammer relatively to itself, and not the world. Are you sure you're using relative, not World Rotation?

avatar image YourBoiCasey Jan 05 '19 at 10:50 PM

alt text

Here is what I have right now. I have RelativeRotation. Here what it looks like : https://youtu.be/q2clPKejKZc

answer.png (125.8 kB)
avatar image Tuerer Jan 06 '19 at 10:12 AM

I see. Your hammer is a child to your camera, and its initial rotation is not 0.0.0. You can either see what the hammer rotation is and type it into A, and the same into B, but with Y-70, or you can do something like this: alt text

hammer.png (113.8 kB)
avatar image YourBoiCasey Jan 06 '19 at 06:00 PM

Hi there! So I solved the problem with my camera following too much the hammer (while he was smashing). I went to the BP of the hammer --> Spring Camera component --> In camera Settings I have unchecked the boxes "Inherit Pitch/Yaw/Roll". Now the camera is following the player when he walks/jumps but stay in place when he rotates. Nice!

Now, my ONLY problem is that the hammer still smash in ONE direction only. Like this :https://youtu.be/GShozyV1fWw

And there is also a problem where I try to smash but since I'm walking the smashing animation by the timeline play super duper fast. You can maybe see it in the video. Is it possible to use a timeline while walking?

Once again, u da man. Thank you for your time. It really helps me to get better!

(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