• 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 mesnosmichael · Aug 06, 2018 at 02:24 AM · drawing

IS That A Unity 2017.2.1f GLITCH???

I Think There Is A Glitch In Unity, I've Been Trying To Solve This For 3+ Days. Ok, Here's My Question,

I'am Making A Paint Game, And I Made Everything, Except My "PaintRuntime" I Tried A Youtuber's Tutorial And It Didn't Work, Then I Tryed Something Else That I Did And Now It Doesn't Work?!?? How? Anyway, Here's What I Tried A Few Days Ago:

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class PaintGM : MonoBehaviour {

 public Transform baseDot;
 public KeyCode mouseLeft;
 public static string toolType;


void Update() { Vector2 mousePosition = new Vector2(Input.mousePosition.x, Input.mousePosition.x); Vector2 objPosition = Camera.main.ScreenToWorldPoint(mousePosition);

     if (Input.GetKey(mouseLeft))
     {
         Instantiate(baseDot, objPosition, baseDot.rotation);
     }
 }

}

I Got An Error: "NullReferenceException: Object Reference not set to an instance of an object" (Line 14)

I Set The Reference In The Inspector, And It Still Says This.... Anyway, Here's What I Tried These 3 Days

using UnityEngine; using System.Collections;

public class SwipeTrail : MonoBehaviour {

 public GameObject trailPrefab;
 GameObject thisTrail;
 Vector3 startPos;
 Plane objPlane;

 void Start()
 {
     objPlane = new Plane(Camera.main.transform.forward*-1, this.transform.position);
 }


 void Update () 
 {
     if((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) ||
         Input.GetMouseButtonDown(0))
     {
         thisTrail = (GameObject) Instantiate(trailPrefab, 
                                                 this.transform.position, 
                                                 Quaternion.identity);
         Ray mRay = Camera.main.ScreenPointToRay(Input.mousePosition);
         float rayDistance;
         if (objPlane.Raycast(mRay, out rayDistance))
             startPos = mRay.GetPoint(rayDistance);
     }
     else if(((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) 
         || Input.GetMouseButton(0)))
        {
          
         Ray mRay = Camera.main.ScreenPointToRay(Input.mousePosition);
         float rayDistance;
         if (objPlane.Raycast(mRay, out rayDistance))
             thisTrail.transform.position = mRay.GetPoint(rayDistance);
        }
        else if((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended) ||
         Input.GetMouseButtonUp(0))
        {
            if(Vector3.Distance(thisTrail.transform.position, startPos) < 0.1)
                Destroy(thisTrail);
        }
 }

}

And I Got The Same Error, Is That A Bug? Because When I Tap/Click To Make A Clone, My Clone Hasn't Got The Script Attached To It And Stuff, But My Main Has The Script On It, How Is that Even Possible??? My Brain Is About To Explode.

If Someone Fiqure This Out Thank You So Much And Btw, im using 2018.2.1f1, I Think There's A New Update But If I Update Then It Will Reset All My Projects.

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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

149 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

Related Questions

Creating Perfect Circle That Can Get Narrower - 2D 0 Answers

Best way to draw squares of changing colors? 0 Answers

Hi , now i making 2d platformer game that can draw line ( using line renderer) , the game is ok if i didnt use camera to follow the player. so how to make the line renderer follow position of camera ? Thanks 0 Answers

Helpp !! Can't draw the rectangle on the gameobject 's positon 0 Answers

Drawing, Writing on screen. 0 Answers


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