#Trying to flip AttackArea after moving to left and right after walking to right

1 messages · Page 1 of 1 (latest)

full cairn
#
using System.Collections.Generic;
using UnityEngine;

public class yon : MonoBehaviour
{
    float inputVertical;
    float inputHorizontal;
    bool facingRight = true;
    
    public Transform AttackArea;
    private Vector3 scaleChange, positionChange;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
        
    }
    void FixedUpdate()
    {
        inputHorizontal = Input.GetAxisRaw("Horizontal");
        inputHorizontal = Input.GetAxisRaw("Vertical");

            if (inputHorizontal > 0 && !facingRight)
        {
            flip();
        }
            if (inputHorizontal < 0 && facingRight)
        {
            flip();
        }
    }

    void flip()
    { 
        Vector3 currentScale = gameObject.transform.localScale;
        currentScale.x *= -1;
        gameObject.transform.localScale = currentScale;

        facingRight = !facingRight;


    }
}```
#

I did this but it is not working

gleaming dragon
#

Can you open that yon script?

#

in the inspector

full cairn
#

ohhh

gleaming dragon
#

@full cairn

full cairn
#

I see

gleaming dragon
#

i see, I guess you know what to do from there

full cairn
#

thx

gleaming dragon
#

there's an empty field where it shouldnt be empty

full cairn
#

I put AttackArea there but it still doesnt work

#

I dont get any errors but

#

Doesnt flip the AttackArea

gleaming dragon
full cairn
#

okay

gleaming dragon
#

why is attack are object disabled by the way

full cairn
#

It gets activated when I click mouse button

gleaming dragon
#

oh okay.. put the yon in the player then

#

updates dont get called in inactive objects

full cairn
#

I tried yon in player

#

I'm not trying to flip the player

#

then activated attackarea and

#

tried

gleaming dragon
#

add a child to that player, then put yon there

#

then make attackarea child of that object

#
player - ON
  YON - ON
    AttackArea - OFF```
#

Should look like this in the inspector

full cairn
#

okay did it

gleaming dragon
#

works now?

full cairn
gleaming dragon
#

I dont think you need it btw

#

you can delete the field

full cairn
#

It didnt work

#

everything is active

gleaming dragon
#

ahhh I overlooked this

inputHorizontal = Input.GetAxisRaw("Horizontal");
inputHorizontal = Input.GetAxisRaw("Vertical");```
#

Change the second to inputVertical @full cairn

full cairn
#

OHhhhhhhhhhhhhhhh

#

Bro thank you so much