Relative Location returns incorrectly after Actor Rotation

I don’t know exactly what you what you need the rotated relative location for but here is what you can get:

  1. Relative Location of a component is just the offset it has to his parent component, it doesn’t change if you rotate the actor
  2. World Location of a component is it’s current position in the world if you just need the position to for example draw a sphere on it, that should do the trick
  3. If you need the current relative distance from your object to the center of the actor it is on, independent from the world position, you can just subtract Actor Location from World Location, which gives you kind of a rotated relative location.

e.g.:
all spheres are drawn to stay for 2s so that you see a little bit of the past locations, the sphere is attached to the Character that is running around

pink sphere is the relative location, which calculates from 0,0,0 location
white sphere world location is current position of the sphere
green sphere ~rotated relative location, or in reality offset to the actor location

Hiya,

I’m currently trying to make use of a relative location within an actor. However, for some reason this relative location within the actor isn’t taking the Actor Rotation into account when returning the position. The image below basically describes what I’m talking about.

Basically, the white sphere is attached to the player (blue sphere) within the actor. The red wireframe sphere is a debug sphere with the world location of the white sphere component as it’s ‘Center’ location input. It’s always in this position above the player regardless of the player orientation/rotation. What I want it to do is have the red wireframe sphere be drawn on top of the white sphere.

I’ve tried multiple different methods, from simply using world location of the component and using the world location of the player + (relative Llocation rotated by actor rotation). Nothing seems to be working. What can I do to fix this?

Thank you for your quick reply!

I’m intending to use this position to push an enemy towards it to help ‘pull’ that enemy along during a slide attack of sorts, to make it easier to keep the enemy in the hitbox and not have it ‘slip out’ like it currently does.

You see, for some reason this just doesn’t work. Below is a picture of the debug blueprint which is running on tick. In this case, I’ve placed the sphere to be a child of the Capsule Component, rather than in combat collisions where I intend it to be. Along with this is a video of the result.

When I have the sphere in question placed within the ‘combat collisions’ as shown below, the green and pink sphere are actually seperate. That may provide a hint to what the issue is. I am using ‘Set Actor Rotation’ to have the player face the mouse cursor.

Thank you again for the quick reply, hopefully this gets figured out.

EDIT: I just tried this on a fresh project, and it works fine. So I’ve done something wrong, I’m just not sure what.

I must admit the video was very confusing.
What’s what in it, in your blueprint you have red yellow green, but in the video green, pink, white?

I also don’t entirly understand what you want to do with it.
If you want to just keep the actor you slide into in a relative position to the player, the world position of the component should do fine.

Oh! I changed the colour before I recorded the gif. It matches yours in your first reply, so here’s a better screenshot. Sorry about that!

I want the actor (enemy) to stay inside the hitbox while the player is sliding/charging and not out mid-charge. Basically, in the gif below, you notice that the enemy is being pushed outside of the hitbox for the attack. This is because of the knockback system I have (Yes, I could disable that while being charge attacked, but that’s a very specific case and would cause other issues like interfering with the movement of the player), which pushes away the enemy based on damage dealt to it. I want it so the enemy would stay inside the middle hit box and be dragged along with the player during the attack, which would look less chaotic and also guarantee the damage of the attack.

k, that’s super strange your video from before would suggest that the sphere 1 is just not rotating

don’t know if the additional component will work for what you want to do.

How is the enemy moved?
Is it a force applied to it when it gets charged into
Or is it moved every tick by hand or how does that work?

If it is a force I would just apply a force that keeps it in the target area

The enemy gets knocked back by the enemy line tracing to the actor that hit them when they’re damaged and adding an impulse in the direction of the impact normal inverted from the line trace, multiplied by the amount of damage received. This part isn’t causing the issue, as the enemy is doing this themselves without any interaction with the player.

the on hit was just an example in which direction the impulse should go,

in your case instead of an impulse in the direction of the impact normal, you need an impulse to keep it in the dash zone, otherwise it will always be pushed out

Heya,

Sorry for the late reply. I forgot to hit post last time and didn’t realise.

Apparently, it works just fine when I make use of the charge attack. During that time, I’m using a different SetActorRotation to keep the player facing (and going) in the same direction. The sphere rendered in the correct position during the charge, but not during the times when the player is meant to face the mouse. I have no idea why that’s like that, but the system I was trying to achieve in the first place seems to work.

The way I do the player mouse location is that I update the rotation of the player using a rotation variable, and after that I do the check for if the player is allowed to move and if the mouse isn’t off the screen (returned position of the mouse = 0,0,0) and update the rotation variable. This way the player doesn’t face the center of the level when the mouse goes off screen (which causes a lot of issues with how the camera works, which is positioned about halfway between the player and the mouse location in the world, so it freaks out) and when the player isn’t meant to be able to move (like when using the charge attack), you cant face another direction.