This is my code:
using UnityEngine;
using System.Collections;
public class Move2 : MonoBehaviour {
private Rigidbody2D myRigidbody;
[SerializeField]
private float movementSpeed;
[SerializeField]
private Transform[] groundPoints;
[SerializeField]
private float groundRadius;
[SerializeField]
private LayerMask whatIsGround;
private bool isGrounded;
private bool jump;
[SerializeField]
private float jumpForce;
// Use this for initialization
void Start ()
{
myRigidbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void FixedUpdate ()
{
isGrounded = IsGrounded ();
float horizontal = Input.GetAxis ("Horizontal");
Debug.Log ("Horizontal");
HandleMovement (horizontal);
}
private void HandleMovement(float horizontal)
{
myRigidbody.velocity = new Vector2 (horizontal * movementSpeed, myRigidbody.velocity.y);
if (isGrounded && jump)
isGrounded = false;
myRigidbody.AddForce (new Vector2 (0, jumpForce));
}
private void HandleInput()
{
if(Input.GetKeyDown(KeyCode.UpArrow))
{
jump = true;
}
}
private void ResetValues()
{
jump = false;
}
private bool isGrounded()
{
if (myRigidbody.velocity.y <= 0) {
foreach (Transform point in groundPoints) {
Collider2D[] colliders = Physics2D.OverlapCircleAll (PointEffector2D.position, groundRadius, whatIsGround);
for (int i = 0; i < colliders.Length; i++) {
if (colliders *.gameObject != gameObject) {*
-
return true;*
-
Debug.Log ("isGrounded");*
-
}*
-
} *
-
}*
-
}*
-
return false;*
- }*
}
I am getting the error that my type Move2 (the name of the file) already contains a definition for isGrounded. I am very new to this, so I most likely missed something obvious. I am using parts of an InScopeStudios tutorial on a 2D platformer, only taking the parts on movement. Thank you!