Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by zak666 · Jan 30, 2016 at 05:15 PM · scripting problem

AI and player guns not fireing, have i missed a step here? error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Hi gang, just tested my game everything is set up and YES everything has ridgid bodies and triggers and tags have been set however my guns fail to fire.

have a box extruding out from the AI-bot and set to trigger as player enters this triggerbox it acts as aline of sight and sets fireing to true sdo the bot can fire at the player. error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

 using UnityEngine;
 using System.Collections;
 
 public class ET_AI_ : MonoBehaviour {
 
     // OUT THIS SCRIPT ONAI ET FIGHTER HITBOX.
     //guns:
     public GameObject Gunslocation;
     public GameObject bulletPrefab;
     public AudioClip GunsETFighter; 
     public int IsShooting = 0;
     public int GunsFireing = 1;
     public int Gunsoff = 0;
     public int firerate = 12;
     public int burstrate = 5;    
 
     // If Player Enters Trigger:
 //---------------------------------------------------------------------------------------------------------------------
 
     void OnTriggerEnter(Collider  Collider)
     {
         if(GetComponent<Collider>().tag == "Player")
         {
             IsShooting  ==  GunsFireing;
         }
 
     } // End triggger
 
 //---------------------------------------------------------------------------------------------------------------------
 
         void OnTriggerExit(Collider  collider2)
     {
         if(collider2.tag == "Player")
         {
             IsShooting == Gunsoff;
         }
 
     } // End triggger
 
 //---------------------------------------------------------------------------------------------------------------------
 
     // if can shoot fire guns.
     void Update()
     {
         if (IsShooting > 0) {
             if(IsShooting > 0) StartCoroutine(FireBurst(bulletPrefab,1,10));        }
     }
 //---------------------------------------------------------------------------------------------------------------------
       IEnumerator FireBurst(GameObject bulletPrefab, int burstSize, float rateOfFire)
     {
         float bulletDelay = 60 / rateOfFire; 
         // rate of fire in weapons is in rounds per minute (RPM), therefore we should calculate how much time passes before firing a new round in the same burst.
         for (int i = 0; i < burstSize; i++)
         {
             Rigidbody clone2;
             clone2 = (Rigidbody)Instantiate (bulletPrefab, transform.position, transform.rotation);
             yield return new WaitForSeconds(bulletDelay); // wait till the next round
             Debug.Log("I Am Fireing");
         }
     }
 }
 



Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bonfire-Boy · Jan 30, 2016 at 07:00 PM

In brief... lines 24 and 35 you've put == where it should be =

This IsShooting == Gunsoff; is a comparison, but you're not doing anything with it. That's what the error message is complaining about. Presumably you're trying to assign a value, which would be IsShooting = Gunsoff;

I'm confused by your description of the problem, though. "X not firing" sounds like it's running but not working properly. But the error is a compiler error, so I wouldn't expect it to be running at all.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

37 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

3D Survival Shooter Tutorial Movement Code Errors 0 Answers

ScriptableObjects instances and RAM usage. 0 Answers

input.getaxis not working 2 Answers

Why do i get NullReferenceException here? 1 Answer

HELP ME PLEASE! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges