- Home /
Camera relative movement (CharacterController.Move) in one axis and local transform
Hello there, I have done a construction to climb and move along edges and another one for pushing objects. The problem is the inputs. I already have relative to camera movement but in this case I couldn't figure out how to implement this. Because I use the normals from the wall on which the player is hanging to rotate towards the wall, so I can move in the left or right Direction. (The player is constantly moving forward to be in front of the wall and to get the normal)
Vector2 LedgeInput = input;
LedgeInput.y = 0;
LedgeInput = LedgeInput.normalized;
Vector3 moveDirectionLedge;
moveDirectionLedge = LedgeInput * Time.deltaTime * 2;
moveDirectionLedge = transform.TransformDirection(moveDirectionLedge);
if (LedgeInput.x < 0.9f && canUseInput && isLeftSideFree)
{
anim.SetBool("LedgeLeftPressed", true);
cController.Move(moveDirectionLedge);
}
else
{
anim.SetBool("LedgeLeftPressed", false);
}
if (LedgeInput.x > -0.9f && canUseInput && isRightSideFree)
{
anim.SetBool("LedgeRightPressed", true);
cController.Move(moveDirectionLedge);
}
else
{
anim.SetBool("LedgeRightPressed", false);
}
Because of this I need local Transform. And the other problem is, I only use left and right (xAxis) to move along edges.
And for the pushing thing it's almost the same. There I use the yAxis.
Maybe someone can tell me and explain how I can make this.
I hope you can Understand me.
Answer by MrGurbiful · Aug 18, 2019 at 02:38 PM
Now I have this:
Vector2 LedgeInput = camForward * input.y + camRight * input.x;
LedgeInput.y = 0;
LedgeInput = LedgeInput.normalized;
Vector3 moveDirectionLedge;
moveDirectionLedge = LedgeInput * Time.deltaTime * 2;
moveDirectionLedge = transform.TransformDirection(moveDirectionLedge);
if (canUseInput && isLeftSideFree)
{
anim.SetBool("LedgeLeftPressed", true);
cController.Move(moveDirectionLedge);
}
else
{
anim.SetBool("LedgeLeftPressed", false);
}
if (canUseInput && isRightSideFree)
{
anim.SetBool("LedgeRightPressed", true);
cController.Move(moveDirectionLedge);
}
else
{
anim.SetBool("LedgeRightPressed", false);
}
It isn't the solution but I am near to it. Maybe now someone have an idea?