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 /
avatar image
0
Question by ViniGirotto · Aug 18, 2011 at 12:50 PM · raycastmouseselect

Select instantiated object with mouse

Hello,

Im having some problems with this script im working on to select an object, im getting an error saying: unknown identifier:'color'. and 'changeColorRed' is not a member of 'unityEngine.Transform'.

Im a started at scripting, so i belive maybe i am putting something in the wrong order that maybe could be the problem.

heres the script:

var selecaoMouse : Transform;

var ray : Ray = camera.main.ScreenPointToRay (Input.mousePosition); var hit : RaycastHit;

Debug.DrawRay (ray.origin, ray.direction * 100, Color.yellow);

function changeColorRed()

{ selecaoMouse.renderer.material.color = color.red;

}

if (Physics.Raycast (ray.origin, ray.direction, hit, 100))

{

 if(hit.collider.tag == "Object")
 {
 
     var object : GameObject = hit.collider.gameObject;
     if(object != selecaoMouse) //new object selected
     {
     
         selecaoMouse.changeColorRed(); //unselect object
         selecaoMouse = object;
     }
 
 }

}

im trying to figure out which is the problem with this script, i saw many examples of similar ones here on unity answers, but for some reason i couldnt make this work, i would appreciate some help on the subject

thanks for the attention

Vinicius Girotto

Comment
Add comment · Show 1
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 Julien-Lynge · Aug 18, 2011 at 03:28 PM 1
Share

ViniGirotto, Just as your error message says, your function changeColorRed() is not a part of the definition of Transform.

Ins$$anonymous$$d of selecao$$anonymous$$ouse.changeColorRed();, you need to call changeColorRed();

However, it looks like your bigger problem is that you don't know how to program in JavaScript. There really is no shortcut around it - you need to spend some time reading up on how object oriented languages work.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ViniGirotto · Aug 18, 2011 at 04:25 PM

Thanks for the support, and indeed i dont know how to program in JavaScript, i mean, i am learning the syntax and the concepts while doing this project. There are some programming concepts that are still a bit cloudy to me yet, anyway thanks for the attention, i managed to make it work after yout tips, and ill keep on with the studies now.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

C# mouse Raycast question 3 Answers

How to NOT select an object behind a GUI? 1 Answer

Move selected object. 1 Answer

Intersection point of mouse with ZX plane 1 Answer

how can i Find an object height, while click on that object? 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