using System.Collections.Generic;
using UnityEngine;
public class playercombat : MonoBehaviour
{
public Animator animator;
public Transform attackPoint;
public float attackRange = 0.5f;
public LayerMask enemyLayers;
public float AttackRange { get => attackRange; 0.5f => attackRange = 0.5f; }
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
Attack();
}
}
void Attack()
{
animator.SetTrigger("Attack");
Physics2D.OverlapCircleAll(attackPoint.postion, AttackRange, enemyLayers);
foreach (Collider2D enemy in hitEnemies)
{
Debug.lot("Hit" + enemy.name);
}
}
void OnDrawGizmosSelected()
{
if (attackPoint == null)
return;
Gizmos.DrawWireSphere(attackPoint.position, AttackRange);
}
}
A get or set accesssor expected. What does that mean and how should I fix it?
Assets\playercombat.cs(13,52): error CS1014: A get or set accessor expected
Assets\playercombat.cs(13,60): error CS1014: A get or set accessor expected
>Solution :
Your setter on AttackRange is weird. KYL3R’s answer implies that you want to set attackRange to 0.5f whenever you set it, no matter what you set it to. That seems equally weird. I think you want
public float AttackRange { get => attackRange; set => attackRange = value; }