Moving an object by pointing another object at it

Hoping someone could help me with a hypothetical, or point me in the right direction. Let’s say I have a first person character, a cube and a sphere. I want the character to be able to pick up the cube and point it at the sphere, which causes it to move vertically from point A to point B. Then, when the cube is no longer pointing at it, the sphere floats back down to point A. And it’s triggered regardless of where the sphere is, for instance, if I point the cube at the sphere and it moves to point B, then I stop pointing and it starts to go back to A ( only halfway to it), then I point at it again and it starts going to point B again. I was thinking of a line trace from the cube to the sphere, as I know how to make an object do something through the line trace and can set it to trigger when the object is picked up, but I don’t understand how it would go back to its original position when not casting the trace.

See if this :point_down: helps with this :point_up_2: particular bit.

  • a standard forward camera trace:

You’d use an interface or inheritance if there are more types to handle, ofc.

  • not sure how you want stuff to move, here it’s via a timeline:

  • which results in:

  • the branches in the script prevent it from spamming since we’re tracing on Tick:

Hopefully you can adapt it to your needs.


It’s a setup similar to this one:

This is perfect thank you! I think I tried the branch out of the return node from the trace which is where I went wrong with it- and didn’t realise that there was a “blocking hit” node. total noob.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.