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

Referencing and Executing Script Can't Be Done due to Not Being A Statement

$
0
0
I keep getting an error CS0201 on the lines (31,13). It says that only assignment, call, increment, decrement, await, and new object expressions can be used as a statement. If I were to just put in the variable reference by itself, it shows no errors but it doesn't execute the referenced code. How can I reference the other script in the same game object as the one shown? using System.Collections; using System.Collections.Generic; using UnityEngine; public class playerController : MonoBehaviour { public float moveSpeed = 5f; public Rigidbody2D rb; Vector2 movement; Vector2 mousePos; public Camera cam; public Shooting shooting; // Start is called before the first frame update void Start() { shooting = GetComponent(); } // Update is called once per frame void Update() { movement.x = Input.GetAxisRaw("Horizontal"); movement.y = Input.GetAxisRaw("Vertical"); mousePos = cam.ScreenToWorldPoint(Input.mousePosition); if (Input.GetButtonDown("Fire1")) { shooting; } } void FixedUpdate() { rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime); Vector2 lookDir = mousePos - rb.position; float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f; rb.rotation = angle; } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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