My Issues:
Assets\Scripts\Player.cs(22,17): error CS1519: Invalid token ‘=’ in class, struct, or interface member declaration
Assets\Scripts\Player.cs(23,8): error CS1519: Invalid token ‘=’ in class, struct, or interface member declaration
Assets\Scripts\Player.cs(23,35): error CS1519: Invalid token ‘(’ in class, struct, or interface member declaration
Assets\Scripts\Player.cs(23,36): error CS8124: Tuple must contain at least two elements.
Assets\Scripts\Player.cs(23,37): error CS1519: Invalid token ‘;’ in class, struct, or interface member declaration
Cannot move asset from Assets/Scripts/TopDownController.cs to Assets/Scripts/Player.cs. Destination path name does already exist
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
My Scripts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public Camera sceneCamera;
public float moveSpeed;
public Rigidbody2D rb;
public Weapon weapon;
public static float healthAmount;
private Vector2 moveDirection;
private Vector2 mousePosition;
void Start ();
healthAmount = 1;
rb = GetComponent();
// Update is called once per frame
void Update()
{
if (healthAmount <= 0)
Destroy (gameObject);
// Processing Inputs
ProcessInputs();
}
void FixedUpdate()
{
// Physics Calculations
Move();
}
void ProcessInputs()
{
float moveX = Input.GetAxisRaw(“Horizontal”);
float moveY = Input.GetAxisRaw(“Vertical”);
if(Input.GetMouseButtonDown(0))
{
weapon.Fire();
}
moveDirection = new Vector2(moveX, moveY);
mousePosition = sceneCamera.ScreenToWorldPoint(Input.mousePosition);
}
void Move()
{
rb.velocity = new Vector2(moveDirection.x * moveSpeed, moveDirection.y * moveSpeed);
// Rotate Player to follow Mouse
Vector2 aimDirection = mousePosition - rb.position;
float aimAngle = Mathf.Atan2(aimDirection.y, aimDirection.x) * Mathf.Rad2Deg - 90f;
rb.rotation = aimAngle;
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.name.Equals (“Enemy”))
healthAmount -= 0.1f;
}
}
}
Script 2:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HealthBar : MonoBehaviour
{
public Vector3 localScale;
// Start is called before the first frame update
void Start()
{
localScale = transform.localScale;
}
// Update is called once per frame
void Update()
{
localScale.x = Player.healthAmount;
transform.localScale = localScale;
}
}