Location issues of blueprint with bobbing

Having trouble with some conflicting code. They both work fine separately, but not together. This issue is that When an event is called, I want an object to move in the x and y, then back again. However I also want it to bob up and down on the z continuously, regardless of the x/y axis. I tried spitting the structs, and only setting the z location for the bobbing, but then when playing it shoots the object off in the x/y axis

For bobbing on the Z

For moving away

In the second graph, your line trace is in line from the (0,0,0) to your character location in that direction. Not sure that’s what you want.

As for the bobbing, your bob distance calculation is a scalar value. IOW, it’s a single value, not a vector. When you add it to your RelativeLocation, it’s going to convert your scalar to a vector. Said plainly, it will duplicate your value to the X,Y and Z values of the vector before adding it. So the culprit is your addition node.

You need to create a (0, 0, BobZ) vector.

Use the make vector node and connect it to the addition node. Connect the output of your last multiplication to the Z value of make vector.

This is the revised graph—its also facing the camera. This works, but the line trace still isn’t. Basically, when I call this hand trigger event, my hand is overlapping the mesh. Then I want the mesh to just move backward a bit, then return to its original position, like I’m poking it.

or should I not do a line trace, am I making it too complicated? Wherever I am in the scene, I need it to move away from me x amount then return

I’m not sure what you’re trying to do with the line trace. If you have an actor that you just want to move directly away, you can just calculate how far and get a coordinate and then use MoveTo to move the actor there if it’s using an AIController. You seem to be moving it manually though. This is why I’m not certain what your design or plan is.

Either way, I think you’re having difficulty with the end point. If you want an actor to move directly away from your character, then this is the math:

This will move OtherActor away in the direction opposite to CurrentActor for a distance of UnitsToMove. This location is stored in MoveLocation. To return back, return to OriginalLocation.

This doesn’t work for me/not moving it. It’s not an Ai controller. Yeah I got rid of the line trace, not sure what I was thinking there either–Regardless of what I do on the moving of the object away, the bobbing on the tick prevents it. If I disconnect the bobbing, then whatever works. So That’s what I did, and instead just made an animation of it moving up and down. The object is floating in space at a fixed location-not wandering around. So what I’m trying to do is (1) have the object always facing me as I move around it. (2) whenever I call this event (I touch it), the object floats backwards away from that touch a certain distance, from whichever way its currently facing me. then after a delay, returns make to the original position. So like the picture, whether I’m in the “green” location or the “red”, the object moved opposite of me. Then always returns.

I did this instead of the line trace, this works, but I cant get it to come back to the original position, I tried to reverse this, but when it moves back, it keeps coming closer and closer to the player. i.e., if its currently at 5,5 on the x/y, the event is called and it moves away from the player to 6,6, then it moves back to 4.5,4.5 instead of 5,5.

This doesn’t work for me/not moving it. It’s not an Ai controller. Yeah I got rid of the line trace, not sure what I was thinking there either–Regardless of what I do on the moving of the object away, the bobbing on the tick prevents it. If I disconnect the bobbing, then whatever works. So That’s what I did, and instead just made an animation of it moving up and down. The object is floating in space at a fixed location-not wandering around. So what I’m trying to do is (1) have the object always facing me as I move around it. (2) whenever I call this event (I touch it), the object floats backwards away from that touch a certain distance, from whichever way its currently facing me. then after a delay, returns make to the original position. So like the picture, whether I’m in the “green” location or the “red”, the object moved opposite of me. Then always returns.

I did this instead of the line trace, this works, but I cant get it to come back to the original position, I tried to reverse this, but when it moves back, it keeps coming closer and closer to the player. i.e., if its currently at 5,5 on the x/y, the event is called and it moves away from the player to 6,6, then it moves back to 4.5,4.5 instead of 5,5.

AH! just realised I saved the original location on begin play. Typically over complicating things, This moves it back.

The blueprint I gave you calculates the start and end positions. It doesn’t move anything. That’s up to you.

The reason the actor doesn’t return to the correct location is because you’re mixing local and world coordinates. And I’m not certain that your mesh isn’t your root component.

As to why having one animation cancels out the movement is because you’re overwriting the location.

Have the bobbing up and down work on the relative location of your mesh. Should be ok as is.

But have the movement work on the location of your actor and make sure your mesh isn’t the root component.

So in your MoveAway event, call the blueprint event I gave you. And plug those variables into your LERP node. Delete the rest of the graph that does all the calculations. Replace Set Relative Location to Set Actor Location, but only for the MoveAway event. When your timeline is completed, just use another timeline with the start and end swapped in your lerp.

Something like this:

edit: In the CalculateLocation event, CurrentActor would be Get Player Pawn 0. And OtherActor would be Self if this blueprint is in the actor that is moving away.

The mesh was the root, maybe part of why there was some issue. Just made a new test BP. This together works, but I need it to not be affected on the Z. The object is floating in space, and I need it to stay at whatever height I place it at. I’m not sure where I need to split the struct , on the calculate event or everywhere.

The root component is the actor location. So for what you need to do, you don’t want your mesh to be your root component. A capsule or the usual default scene component is fine for the root component.

Your graph looks fine. Re-add your bobbing graph from your original post to your tick event and you should be good.

So the Z bobbing is done on the relative Z location of the mesh while the XY movement is done on the actor itself (ie. the root component). This means you’re modifying TWO different vectors with their own XYZ values.

edit: Oh, you want the same Z overall when moving away. To do that, you need to copy the Z from original location into move location in CalculateLocation. Here’s one way to do that.

I’ll keep the bobbing off- the animation looks more organic anyway. but yes this works! thank you so much for your help!

Ah nice! Glad it worked!