Helllo, As I said I have a problem with Surface effector and it doesn’t work because of this script Here’s the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HeroController : MonoBehaviour
{
Animator anim;
public float speed;
public Rigidbody2D rb;
public float jumpforce;
// Start is called before the first frame update
void Start()
{
anim = GetComponent();
rb.GetComponent();
}
// Update is called once per frame
void Update()
{
float horizontalDir = Input.GetAxisRaw(“Horizontal”);
anim.SetFloat(“horizontalDir”, Mathf.Abs(horizontalDir));
rb.velocity = new Vector2(horizontalDir * speed, rb.velocity.y);
if(horizontalDir < 0)
{
transform.localScale = new Vector3(-1f, 1, 1);
}
if(horizontalDir > 0)
{
transform.localScale = new Vector3(1f, 1, 1);
}
if (Input.GetKeyDown(KeyCode.W))
{
rb.AddForce(new Vector2(0, jumpforce));
anim.SetTrigger(“Jump”);
}
}
}