I can't solve flip 2D char's problem XoX,I need help!! [Rigging 2D Character]

I’ve been trying to flip character yesterday and it work but something strange.When My Character flipped
It teleport to the other side instead :confused: .I try to solve it but it isnt work ToT I dont know how to solve this problem


.
[I cant send the VDO] In an image . You see?!, both were processes when I flipped.
.
I need help for this .ToT I want to flip my character without changing position. :d

And here is my code.

public class Bells : MonoBehaviour
{
    const float GCC = 0.2f;
    public float speed = 1f;
    public float jumped = 9f;
    public float maxspeed = 10f;
    public float jumppower = 20f;
    public bool ground;
    public float JR = 1f;
    public float Jcool = 0.0f;
    public float FireRate = 0.2f;
    public float nextFR = 0.0f;
    private Rigidbody2D rb;
    private Physics2D phy2d;
    Animator anim;
    public int HP = 100;
    private void Start()
    {
        rb = this.GetComponent<Rigidbody2D>();
        anim = this.gameObject.GetComponent<Animator>();
    }

    private void Update()
    {
        anim.SetBool("Ground",true);
        anim.SetFloat("speed", Mathf.Abs(Input.GetAxis("Horizontal")));
        if (Input.GetAxis("Horizontal") < -0.1f)
        {
            transform.Translate(Vector2.right * speed * Time.deltaTime);
            transform.eulerAngles = new Vector2(0, 180);
        }
        else if(Input.GetAxis("Horizontal") > 0.1f)
        {
            transform.Translate(Vector2.right * speed * Time.deltaTime);
            transform.eulerAngles = new Vector2(0, 0);
         

        }
        if (Input.GetButtonDown("Jump") && Time.time < Jcool)
        {
            anim.SetBool("Jump", true);
            Jcool = Time.time * JR;
            rb.AddForce(jumped * (Vector2.up * jumppower));
        }
        else
        {
            anim.SetBool("Jump", true);
        }
        if (Input.GetKey(KeyCode.J) && Time.time > FireRate)
        {
            nextFR = Time.time + FireRate;
            anim.SetBool("Attack", true);
        }
        else
        {
            anim.SetBool("Attack", false);
      
        }


      
    }
    private void FixedUpdate()
    {
      
    }

     
  
}

update event Xd
i think the real problem must be icon(the sim) point.

I cant move it :confused: anyone answer me please:/ :confused: :d
If this one isn’t involved with the problem please tell me how to solve this post’s problem :3

I’ll delete your previous duplicate post. Please note that you can edit your posts. :slight_smile:

its because of the pivot, you need to set pivot on the center of the sprite

Also, you do NOT modify the Transform when using physics. You added a Rigidbody2D, its job is to write to the Transform. By directly modifying the Transform, you’re bypassing physics, specifically what the Rigidbody2D is trying to do.

In some circumstances you need to modify the Transform but those should be limited to only when something changes and should be restricted to scaling only for when you need to:

  • Flipping by using negative X or Y local scale.
  • Changing the overall scale

Oh,i see .i noticed that too but i don’t know how to set it to the right position .
Thanks you for your help!!! :smile:

Oh,I see . Thank you for ur help !! :smile:

normally its on the sprite renderer

I’ve done but it doesnt work what did i do wrong :confused: I’m curious. :confused:

I thought it doesn’t work because i did it once by coding negative X-Axis.

private void FixedUpdate()
{
move(hotazontalValue); 
}

void move(float dir)
{
float xVal = dir * speed * 100 * Time.deltaTime;
Vector2 targetvelocity = new Vector2(xVal,rb.velocity.y);
rb.velocity = targetvelocity;

if (RightMove && dir < 0) 
{
transform.localScale = new Vector3( -1, 1, 1);
RightMove = false;
}
else if(!RightMove && dir > 0)
{
transform.localScale = new Vector3(1, 1, 1);
RightMove = true;
}

}

Correct? :smile:

I found something:/ My character isnt in sprite renderer.9181532--1279010--Screenshot 2023-07-30 185552.png

I cant put my body in it :confused:

where is it then?

Sprite > None(Sprite) ,I dont sure because in YT, There is sprite in sprite box.

magic =3

XoX