How do I move a static mesh inside of a blueprint?

Hello, I am currently working on a puzzle game which has a puzzle box. The puzzle box you can grab and move closer into view and then rotate it to have a look around. There are little gems on the side of the box that need to move left or right by mouse click and I’m not sure how to do it.

So far I have got it so that you can freely use the mouse cursor as its shown on screen when you pick up the puzzle box, and then use line tracing to click where needed. But I now need to click on a gem and move it either left or right so you are sliding the gem on the box to the correct position but every time I try the gem normally shoots off to a different position.

The aim of the puzzle box is to move the gems in the correct position (left or right) to open the box.

link text

The link is of what I have so far.

You need to move them in relative space - that’s assuming the gem meshes are attached to the box. So rather than using Set World Location, use Set Relative Location.

I was using the relative location in the first place and it kept disappearing, felt like an idiot when I realised it was disappearing inside its self… one thing I’ve notice though, is that it’s, moving from the root of the scene and not it’s own pivot point.

I’m an idiot and I’ve just figured out why, I didnt have my settings correct on my lerp and location on my relative. THANK YOU for the help :stuck_out_tongue:

Sorry for the spamming, but do you know why if I click on the box that it moves the gem? How do I set it to just clicking on the gem will move it?

The most universal way would look like this:

You’re probably doing some tracing in which case you may want to isolate what you’re tracing against. Otherwise, the above should work providing you enable Click Events in the Player Controller.

If it gives you a headache, do consider attaching the blueprint (screenshot) that does the tracing.

edit:

For example: if you’re doing tracing, give the Gem meshes a tag, when you trace, check if the hit component is a gem, if True, move it. Hard to advise without seeing how you set it up.

if you want the gem to move between two preset points you may want to consider using two scene components as the start and end locations. this will make things easier to visualize and to script.

You my dude are a babe! I am using a line trace on click to make the gem move and the tag is now working!

Agreed, this opens up for a more procedural approach where you set up target points and refer to them as locations. You’d no longer need to hardcode or update the move destinations for the gems in case your design changes or you need to tweak it. A bit more upfront work but totally worth it in the long run!