Vector Length Limitations

Hey guys, quick question;

I have a character in game that when I press the left mouse button, it spawns a ‘ghost’ of something. Now I want that ghost’s location to be limited to a certain distance from my character (this will stop that ghost from going everywhere around my map).

Is there a good way on doing this?

From what I heard, ‘Vector Length’ would be the best way to go, but even then, I’m not sure on how to approach this.
Assuming everything else is set up, and all that is needed is the ghost location limits, how will I go about doing this?

From how my logic works (which it doesn’t), i would assume:

  • I need to obtain the character world location
  • Then get the ‘ghost’ actors location (‘Get Actor Location’)
  • I would then have to find a point in between these two (close to the character)
  • Then if the ‘Ghost’ is out of these limits, than set its location to that limit (some how)

Hopefully this makes sense to you all, if not, please tell me what I need to elaborate this issue.

Thank you

Do you want random positions or set positions?

Set once it passes the limits

OK, if I have you right,

You need to find the distance between the 2 actors. Get Vector Length.

If length over x distance, move ghost back with range.

This is not right, but you are looking for something like this?

Yeah this is what i am after. I need a point in between my character and the ‘Ghost’ to set as the limits. Then, If the ghost goes beyond those limits, then it will just stay there at that maximum limit (even if i move my mouse around the outside of that limit, the will move, but NOT outside those limits).
… if that makes sense

Ok

Someone will clean this up or correct a bit, but something closer to this? Off false you would stop simple move to and run your usual movement.

Hey ! Thanks for the help, but i think i have figured out what i needed…

However

Now i just have to figure out how to set the new location of the ‘Ghost’ actor to where it’s Last limited location was

And also update it to where my cursor is (without it going passed the boundaries).

Any ideas?

Worked it out:

Just using a set component to set its location :slight_smile: Because the character always facing the mouse anyway.

Thanks guys!