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! :slight_smile:
alt text

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

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

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! :smiley:

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.

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

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?

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”?

Here is what I have right now. I have RelativeRotation.
Here what it looks like :

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:

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 :

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!

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 : )

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

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.

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

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

264763-inspector.png

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.

264764-ham.png

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.

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.

OH MY GOD IT WORKS! AND IT MAKES SO MUCH SENSE IT HURTS MY BRAIN.

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! :slight_smile:

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 :slight_smile:

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.