Hi there guys i have a problem in my script this script is came from tutorial and im wondering if some one here can help me in my problem.
Assets/PlayerController.cs(103,11): error CS1501: No overload for method OverlapSphere' takes
1’ arguments
in Video Tutorial that script is working perfectly and fine but when i try on me i got that error im already editing it for days and i cant fix it so i decided to ask for help When i try to click Start button in game Scene is says All compiler error have to be fixed before you can enter in playmode. Thankyou in advance guys
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PlayerController : MonoBehaviour {
public Animator anim;
[Header(“Movement”)]
private bool canMove;
public float movementSpeed;
public float velocity;
public Rigidbody rb;
[Header(“Combat”)]
private List enemiesInRange = new List();
private bool canAttack = true; //new
private bool attacking;
public float attackDamage;//new
public float attackSpeed;//new
public float attackRange;//new
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
GetInput();
Move();
}
void GetInput(){
//Attack
if(Input.GetMouseButtonDown(0)){
print(“Attacking”);
Attack();
}
//move left
if(Input.GetKey(KeyCode.A)){
SetVelocity(-1);
}
else if(Input.GetKeyUp(KeyCode.A)){
SetVelocity(0);
anim.SetInteger(“Condition”, 0);
}
//move right
if(Input.GetKey(KeyCode.D)){
SetVelocity(1);
}
else if(Input.GetKeyUp(KeyCode.D)){
SetVelocity(0);
anim.SetInteger(“Condition”, 0);
}
}
#region MOVEMENT
void Move(){
if(velocity == 0){
// anim.SetInteger(“Condition”, 0);
return;
} else {
//we can only move if we are not doing something that doesn’t allow us to move.
if(canMove){//changed
anim.SetInteger(“Condition”, 1);
rb.MovePosition(transform.position + (Vector3.right * velocity * movementSpeed * Time.deltaTime));
}
}
}
void SetVelocity(float dir){
//look left or right depending on the (- +) of dir.
if(dir < 0) transform.LookAt(transform.position + Vector3.left);
else if(dir > 0) transform.LookAt(transform.position + Vector3.right);
velocity = dir;
}
#endregion
#region COMBAT
void Attack(){
if(!canAttack) return; //Changed
anim.SetInteger(“Condition”, 2);
StartCoroutine(AttackRoutine());
StartCoroutine(AttackCooldown()); //new
}
IEnumerator AttackRoutine(){
canMove = false;
yield return new WaitForSeconds(0.1f);
anim.SetInteger(“Condition”, 0);
yield return new WaitForSeconds(0.65f); //Changed
canMove = true;
}
//New
IEnumerator AttackCooldown(){
canAttack = false;
yield return new WaitForSeconds(1/attackSpeed);
canAttack = true;
}
void GetEnemiesInRange(){
Physics.OverlapSphere(transform.position + transform.forward);
}
#endregion
}