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 .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 anyone answer me please:/ :d
If this one isn’t involved with the problem please tell me how to solve this post’s problem :3
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: