How do I get a character's movement vector?

So, I’ve got this laser:

And I thought I was being real clever until I found this:

So clearly, I need a different solution, but getting the player’s velocity vector didn’t seem to work. Is there a different vector for direction of motion I could negate?

It’s not clear what the issue is. “the laser is borked”? What is the intended use?
When you get a forward vector, you might want to ask yourself:

  1. forward vector of the player character? a component on it?
  2. forward vector of the camera?
  3. forward vector of the laser?

The Player Controller is just part of the player possessing characters and processing its own user input. A forward vector can be retrieved from many places.

Haha, this is a cool thing. Had some fun playing with it right now.

Try something like this. I suggest you be careful with the values or use clamp like I did, otherwise if you hit it at the “right” angle you might be launched into afterlife, hehe :slight_smile:

You can get your player character and since it does come with movement component out of the box you can access velocity right away.

1 Like

Apologies, let me clarify. It’s suppose to knock the player away from the lazer. In this case, the forward vector is where the player is looking, not moving. So the borked bit is you can turn around and get pushed through the lazer instead of away from it.

Is there a way to get a forward vector that represents the direction of movement instead of the direction of the camera?

I also tried getting a valid vector from the laser itself, but none of the ones I tried worked consistently and I’d really rather not have to worry about my laser’s orientation if possible.

1 Like

This works perfectly, thank you!

1 Like

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