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 Imeguras · Sep 08, 2016 at 10:34 AM · c#camerafloatcamera movementsharing

Is my MonoDeveloped Glitchd ???

I know the title must explain the situation...

First I could do a loop in the start

Yesterday i was coding and i see this error saying that Object reference not set to an instance of an Object then i checked what it means(Im not english so...) Readed again and i thaught that was C# that didnt recognized my object so i did in the start method

 > void Start () { Instantiate(edificio)
 > //ignore here transform.position = new
 > Vector3 (500,100,500);

} Pressed play and my pc lags so MUCH when i looked in the hierarchy more than 200 objects were cloned...

  Sharing Integers and bools and Other stuff

So i wanted to make a camera like MOBA Stile But I also wanted that if a bool was true the camera (teleportates) to the object that is being atacked(once again bool checks that) But then One thing happened: The camera only goes 1000 x 500 of the terrain (Looks it is because of the screen) And then i tryed this code to see if this works:

public float goX ; public float goY ; public float goZ ; private float X; private float Y; private float Z; public int getVida; private int setVida; public bool atacado;//atacado means atacked void Start () { getVida = setVida; setVida = 100; goX = X; goY = Y; goX = Z; X = transform.position.x; Y = transform.position.y; Z = transform.position.z; } void Alerta1(){ if (atacado == true) { if (getVida != 0) { atacado = true; }else{ if (getVida == 0) { atacado = false; } } } } void Update () {

if (Input.GetKey ("a")) { setVida = setVida - 20; atacado = true; Alerta1 (); } else { if (getVida == 0) {//vida means life in portuguese Debug.Log ("MORRI");//dead ... DestroyObject (this); } } } }// i did put all the code to see were i was going tried to do it but this two problem appeared

 Couldnt share Int or Bools or other ints

      if(GameObject.Find("edificio").GetComponent<vidaEdificioScratch>().atacado == true){
          setX = GameObject.Find ("edificio").GetComponent<vidaEdificioScratch> ().goX;
          setY = GameObject.Find ("edificio").GetComponent<vidaEdificioScratch> ().goZ;
          setZ = GameObject.Find ("edificio").GetComponent<vidaEdificioScratch> ().goY;
      }

 and then this problem happens if (Input.GetKey ("a")) { setVida = setVida - 20; atacado = true; Alerta1 ();

it keeps doing the code without pressing the letter

Comment
Add comment · Show 2
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
avatar image Imeguras · Sep 08, 2016 at 10:38 AM 0
Share

going to check the aswers tomorow

avatar image Imeguras · Sep 08, 2016 at 10:27 PM 0
Share

Ohh The code is bugged.... Wtf

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jessespike · Sep 08, 2016 at 04:58 PM

Hard to understand your question. What is the exact problem/error? If the variables goX, goZ, goY are public, then they should be accessible.

Are you sure the problem is not that setX and SetY are being set with Input.mousePosition at the start of each frame? I mean there's no use setting SetX, SetY, SetZ with GameObject.Find after the transform.position if Input.mousePosition sets them beforehand.

i maded that way to look more confusing if they entered the source of the game

Don't do that. This shouldn't even be a concern. Keep code easy to read and understandable, for your own sake and for other developers.

Comment
Add comment · Show 1 · 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
avatar image Imeguras · Sep 08, 2016 at 08:01 PM 0
Share

@Jessespike

Hard to understand your question.

yeah is it because of my English or the text is too long and difficult to understand... but im going to topic to be more pleasant to read

First I could do a loop in the start

Yesterday i was coding and i see this error saying that Object reference not set to an instance of an Object then i checked what it means(Im not english so...) Readed again and i thaught that was C# that didnt recognized my object so i did in the start method void Start () { Instantiate(edificio) //ignore here transform.position = new Vector3 (500,100,500);
} Pressed play and my pc lags so $$anonymous$$UCH when i looked in the hierarchy more than 200 objects were cloned...

Sharing Integers and bools and Other stuff

So i wanted to make a camera like $$anonymous$$OBA Stile But I also wanted that if a bool was true the camera (teleportates) to the object that is being atacked(once again bool checks that) But then One thing happened: The camera only goes 1000 x 500 of the terrain (Looks it is because of the screen) And then i tryed this code to see if this works: // a posiçao para onde ir public float goX ; public float goY ; public float goZ ; //Privado so pode mexer isto private float X; private float Y; private float Z;
//vida do edificio public int getVida; private int setVida; //a ser atacado ou n public bool atacado;//atacado means atacked
void Start () {
getVida = setVida; setVida = 100; goX = X; goY = Y; goX = Z; X = transform.position.x; Y = transform.position.y; Z = transform.position.z; } void Alerta1(){ if (atacado == true) { if (getVida != 0) { atacado = true; }else{ if (getVida == 0) { atacado = false;
} } } }
void Update () {

if (Input.Get$$anonymous$$ey ("a")) { setVida = setVida - 20; atacado = true; Alerta1 (); } else { if (getVida == 0) {//vida means life in portuguese Debug.Log ("$$anonymous$$ORRI");//dead ... DestroyObject (this);
} } }
}// i did put all the code to see were i was going tried to do it but this two problem appeared

Couldnt share Int or Bools or other ints

         if(GameObject.Find("edificio").GetComponent<vidaEdificioScratch>().atacado == true){
             setX = GameObject.Find ("edificio").GetComponent<vidaEdificioScratch> ().goX;
             setY = GameObject.Find ("edificio").GetComponent<vidaEdificioScratch> ().goZ;
             setZ = GameObject.Find ("edificio").GetComponent<vidaEdificioScratch> ().goY;
         }

and then this problem happens if (Input.Get$$anonymous$$ey ("a")) { setVida = setVida - 20; atacado = true; Alerta1 ();

it keeps doing the code without pressing the letter

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

239 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 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 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 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 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 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 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

How to rotate camera diagonally over players shoulder while still facing towards players direction 0 Answers

3d camera not working as I want it to 0 Answers

Smooth camera movement and lookAt [solved] 0 Answers

First person camera snaps when switching cameras 0 Answers

Boolean variable is never true, even if declared true or ticked in the inspector 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