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 /
This question was closed Jan 29, 2017 at 08:13 PM by deathsign092 for the following reason:

doesn't seem like it's gonna be answered

avatar image
0
Question by deathsign092 · Jan 28, 2017 at 02:58 AM · error message

Error CS0120 problem

Hello, everyone. I am attempting to make a simple little grappling hook/rope swinging game.

  var CJ = this.gameObject.GetComponent(typeof(ConfigurableJoint)) as ConfigurableJoint;
 
         if (Input.GetMouseButtonDown(0))
             if (Physics.Raycast(transform.position, Input.mousePosition, 50))
                 CJ.anchor = RaycastHit.point;

This is the code I have currently. To put it simply, I would like to have it so that the anchor for the configurable joint is set to wherever the player clicks in the game area. I am a complete novice at coding, so, any help and suggestions would be greatly appreciated!

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

  • Sort: 
avatar image
1

Answer by hexagonius · Jan 28, 2017 at 10:47 AM

Line 5 is wrong. point is a property of an RaycastHit Object, not the RaycastHit class itself. You need to use the Physics.Raycast version with the out hit parameter. Create a RaycastHit variable before raycasting and use it as the out parameter. Then you can access point from that.

Btw.:

 var CJ = this.gameObject.GetComponent(typeof(ConfigurableJoint)) as ConfigurableJoint;
 
 ==
 
 car CJ = gameObject.GetComponent<ConfigurableJoint>();
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 deathsign092 · Jan 28, 2017 at 08:15 PM 0
Share

Thank you for the reply! I'm grasping it a bit better now, but I'm still having trouble implementing it. If it's not too much trouble, may I ask what you mean by the out hit parameter? I can't seem to do it correctly. (I did get a variable for RaycastHit working, though.)

Follow this Question

Answers Answers and Comments

90 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

Related Questions

Unity WheelCollider.GetWorldPos expecting ), found 'pos' fix ?! 1 Answer

UCE0001 even though i got the semicolon right (i think) 1 Answer

Error CS1519 2 Answers

In Unity 5.3.1f1 (64-bit) version, its block my internet connection!! 0 Answers

Cannot implicitly type Vector2 to camera control 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