Get corners

Hello Guys,
I’m trying to get upper left/right & bottom left/right of the player character by player input & my current script only works when the player rotation is forward after player rotates my script not working.

Those two float variables are from actual keyboard/joystick input.

For example when player press W & A on the keyboard I need upper left & when player press S & A on the keyboard I need bottom left and similar for pressing D for the right side.

Edit:
This is an example of the final result with some trace lines, they are created by the user input (In this case only keyboard used so they’re limited to every 45 degrees), but the problem is when character rotates they are not rotating with character & the endpoints are wrong.

I think it would be much easier if you just put 4 ‘scenes’ into the player BP ( it’s just a point in space ). Put them in the right place, then you can always know where these points are just by getting their world position… :slight_smile:

I know that is possible but I prefer to not using extra actors…

I hear you, but…

It’s not an actor, it’s literally just a point in space. Why bother doing a load of math when you can just put a point somewhere and say ‘that’s the part I mean…’?

Otherwise you’ll need to use something like ‘getboundingbox’ on the player capsule and fiddle about with a little math.

Hello, I have completly no idea what your “script” do but from the description I assume you want to rotate with player. So you just need to use GetActorRotation to get your player rotation and rotate vector by it using rotateByAxis node.

Ok, so you float values are either -1 or 1 right? What do you mean by ‘bottom left’? Some vector value? ( I tried your code, it didn’t do much for me… )

I’ve some reasons, one of them is the player input related to that point & that’s not a static point.

Thanks for your messages & time, but I don’t need “getboundingbox”, I just need a new formula to add character rotation to the current script because my script is working when the player has not any rotation at the beginning.

I added a new screenshot to represent the problem better.

Not a good idea for my use case.

Please check the new screenshot

You can also add sockets to your mesh it will rotate than automaticly and work better.

yes, you can rotate with GetActorRotation and RotateByAxis

I see your doing a trace from the arrow. I think you need to combine the forward and right vectors from the arrow with your controller input to make the trace end point…

So this always points right:

Regardless of player orientation

Feel free to mark it as answered :wink:

Thank you so much problem solved

already tried but link not working!