I’m doing the Tank tutorial:
I am at the point (time stamped in URL) where you take the C# assets code and drag it into the tank but I keep receiving the error "can’t add scrript behaviour AuthorityOnSpawnedObjectsIsCorrect. The script needs to derive from MonoBehaviour.
I keep reading the file name and public class need to match, which they do. This is also the default files from the tutorial provided. I see others having this issue but I have not had a case where it is solved yet.
Here is the file:
(File name is “TankMovement”)
I also tried changing it to “TankMovement.cs”
using UnityEngine;
public class TankMovement : MonoBehaviour
{
public int m_PlayerNumber = 1;
public float m_Speed = 12f;
public float m_TurnSpeed = 180f;
public AudioSource m_MovementAudio;
public AudioClip m_EngineIdling;
public AudioClip m_EngineDriving;
public float m_PitchRange = 0.2f;
/*
private string m_MovementAxisName;
private string m_TurnAxisName;
private Rigidbody m_Rigidbody;
private float m_MovementInputValue;
private float m_TurnInputValue;
private float m_OriginalPitch;
private void Awake()
{
m_Rigidbody = GetComponent<Rigidbody>();
}
private void OnEnable ()
{
m_Rigidbody.isKinematic = false;
m_MovementInputValue = 0f;
m_TurnInputValue = 0f;
}
private void OnDisable ()
{
m_Rigidbody.isKinematic = true;
}
private void Start()
{
m_MovementAxisName = "Vertical" + m_PlayerNumber;
m_TurnAxisName = "Horizontal" + m_PlayerNumber;
m_OriginalPitch = m_MovementAudio.pitch;
}
*/
private void Update()
{
// Store the player's input and make sure the audio for the engine is playing.
}
private void EngineAudio()
{
// Play the correct audio clip based on whether or not the tank is moving and what audio is currently playing.
}
private void FixedUpdate()
{
// Move and turn the tank.
}
private void Move()
{
// Adjust the position of the tank based on the player's input.
}
private void Turn()
{
// Adjust the rotation of the tank based on the player's input.
}
}
How can I have this working? I really want to finish this