我正在使用Unity和Microsoft Visual Studio。我是编码的新手,我不断收到这个错误:
player.start()被标记为覆盖但找不到合适的方法 超控
代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// This is the player script, it contains functionality that is specific to the player
/// </summary>
public class Player : Character
{
[SerializeField]
private Stat health;
[SerializeField]
private Stat mana;
private float initHealth = 100;
private float initMana = 50;
protected override void Start()
{
health.Initialize(initHealth, initHealth);
mana.Initialize(initMana, initMana);
base.Start();
}
/// <summary>
/// We are overriding the characters update function, so that we can execute our own functions
/// </summary>
protected override void Update ()
{
//Executes the GetInput function
GetInput();
base.Update();
}
/// <summary>
/// Listen's to the players input
/// </summary>
private void GetInput()
{
direction = Vector2.zero;
///THIS IS USED FOR DEBUGGING ONLY
///
if (Input.GetKeyDown(KeyCode.I))
{
health.MyCurrentValue -= 10;
mana.MyCurrentValue -= 10;
}
if (Input.GetKeyDown(KeyCode.O))
{
health.MyCurrentValue += 10;
mana.MyCurrentValue += 10;
}
if (Input.GetKey(KeyCode.W))
{
direction += Vector2.up;
}
if (Input.GetKey(KeyCode.A))
{
direction += Vector2.left;
}
if (Input.GetKey(KeyCode.S))
{
direction += Vector2.down;
}
if (Input.GetKey(KeyCode.D))
{
direction += Vector2.right;
}
}
}
答案 0 :(得分:0)
确保您的Character
课程的虚拟方法名为开始