Move a game object when player rotates Unity 2.5D
So I started making a very simple 2.5D game. I have a player and the player has an attack point. From that attack point, I draw a circle and use OverlapCircleAll to deal damage to enemies. The problem is that when I try to move the point with the player, it acts very strange. It randomly moves around, flies 10 km away, etc. I expect the attack point to move with the player and rotate when the player rotates. Thank you.
void Update() {
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
if (Input.GetAxisRaw("Vertical") > 0)
{
AttackPoint.transform.position = new Vector2(0f, this.rb.position.y + 0.2f);
} else if (Input.GetAxisRaw("Vertical") < 0)
{
AttackPoint.transform.position = new Vector2(0f, this.rb.position.y - 0.7f);
}
else if (Input.GetAxisRaw("Horizontal") > 0)
{
AttackPoint.transform.position.Set(this.rb.position.x + 0.2f, 0f, 0f);
} else if (Input.GetAxisRaw("Horizontal") < 0)
{
AttackPoint.transform.position.Set(this.rb.position.x - 0.2f, 0f, 0f);
}
AttackPoint is an empty game object, the type is public transform
Your answer
Follow this Question
Related Questions
Walking around a sprite 1 Answer
[Solved] Problem with achieving rotation relative to current acceleration value 0 Answers
How to reduce the blurring of moving objects on iPhone Screen and MacPro Screen. 0 Answers
Movement/Rotation Methods Don't Work Together 0 Answers
Orbiting Crosshair issue when trying to stop at a specific angle 0 Answers