Hi! I am VERY new to unity, and I was watching a tutorial on how to make a 2D ragdoll move. I have 2 errors after making the movement script:
Assets\PlayerController.cs(22,22): error CS1001: Identifier expected
Assets\PlayerController.cs(39,34): error CS1002: ; expected
Here is my code for the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public Animator anim;
public Rigidbody2D rb;
public float jumpForce;
public float playerSpeed;
public Vector2 jumpHeight;
private bool isOnGround;
public float positionRadius;
public LayerMask ground;
public Transform playerPos;
// Start is called before the first frame update
void Start()
{
Collider2D[] = transform.GetComponentsInChildren<Collider2D>();
for (int i = 0; i < colliders.Length; i++)
{
for(int k = i + 1; k < colliders.Length; k++)
{
Physics2D.IgnoreCollision(colliders[i], colliders[k]);
}
}
}
// Update is called once per frame
void Update()
{
if(Input.GetAxisRaw("Horizontal") != 0)
{
if(Input.GetAxisRaw("Horizontal") > 0)
{
anim.Play("Walk")
rb.AddForce(Vector2.right * playerSpeed);
}
else
{
anim.Play("walk backwards");
rb.AddFoece(Vector2.left * playerSpeed);
}
}
else
{
anim.Play("idle");
}
isOnGround = Physics2D.OverlapCircle(plaperPos.position, positonRadius, ground);
if(isOnGround == true && Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("jumping");
rb.AddForce(Vector2.up * jumpForce);
}
}
}
If it helps, my ragdoll is not exactly the same as the one in the tutorial.
Thanks!