Hello There
So im kinda new to unity and I need some help,
I have a player when I start it teleports to 0,0 and it cant move its only affected by gravity which works fine, here is my player script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerControles : MonoBehaviour
{
public float speed;
private bool facingRight = true;
private float moveInput;
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
var horizontal = new Vector2(Input.GetAxisRaw("Horizontal"), rb.velocity.y);
transform.position = horizontal * speed * Time.fixedDeltaTime;
moveInput = Input.GetAxisRaw("Horizontal");
if (facingRight == false && moveInput > 0)
{
Flip();
}
else if (facingRight == true && moveInput < 0)
{
Flip();
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
}