Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Keep getting "error CS0116: A namespace can only contain types and namespace declarations"

$
0
0
Im very new to Unity so when "error CS0116: A namespace can only contain types and namespace declarations " keeps coming up I have no clue what to do. I checked the My scripts and they say there are no errors. so perhaps You could help? (If I'm writing the question wrong I apologize.) SCRIPT using UnityEngine; /// /// Player controller and behavior /// public class PlayerScript : MonoBehaviour { /// /// 1 - The speed of the ship /// public Vector2 speed = new Vector2(50, 50); // 2 - Store the movement private Vector2 movement; void Update() { // 3 - Retrieve axis information float inputX = Input.GetAxis("Horizontal"); float inputY = Input.GetAxis("Vertical"); // 4 - Movement per direction movement = new Vector2( speed.x * inputX, speed.y * inputY); } void FixedUpdate() { // 5 - Move the game object GetComponent().velocity = movement; } } void Update() { // ... // 5 - Shooting bool shoot = Input.GetButtonDown("Fire1"); shoot |= Input.GetButtonDown("Fire2"); // Careful: For Mac users, ctrl + arrow is a bad idea if (shoot) { WeaponScript weapon = GetComponent(); if (weapon != null) { // false because the player is not an enemy weapon.Attack(false); } } // ... }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>