• 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 /
This question was closed May 01, 2014 at 09:23 PM by robertbu for the following reason:

Multiple technical issues

avatar image
0
Question by Asrock12 · May 01, 2014 at 07:24 PM · mouseclick

Mouse on target

I want to make a game with boat and when you are close to the target(boat), and you point the mouse on it, it will turn like mouse for get in, and when you click you are in the boat.
I believe in you guys. I always will. Hope is my everything

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 robertbu · May 01, 2014 at 09:23 PM 0
Share

Your question reads like a recipe for someone to write some code for you. Unity Answers if or answering single-issue questions to help you write your own code. Here are a few things to reasearch for your many issue:

  • Detecting when the boat is close: Vector3.Distance(), Colliders, OnTriggerEnter().

  • Point with the mouse: Physics.Raycast(), Collier.Raycast(), On$$anonymous$$ouseDown().

  • Turn the boat: Transform.Rotate(), Transform.eulerAngles, Vector3.Slerp(), Vector3.Lerp(), Quaternion.Slerp()

  • Get in the boat: Transform.Translate, Transform.position

Note if you search UA, there are answers with sample source for all the specific issues listed above.

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by akguldeniz · May 01, 2014 at 07:34 PM

you can add your raycast function a if checking by object name. if hits of an target name than add another functions for clicking and boat.

for example var hit : RaycastHit;

  if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3(0,0,1)), hit, 5))
      {
          if(hit.collider.gameObject.name == "Boat"){
               //give an info with gui text in here
              if((Input.GetMouseButtonUp (0)))
              {
                    //Get on the boat function
              }
          }  
      }
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
avatar image
1

Answer by Pigifying · May 01, 2014 at 07:34 PM

You may need to deal with raycasting in some code so here is a reference

Click this

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

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

22 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

Related Questions

How To Perform A Mouse Click On Game Object 5 Answers

Mouse controlled Laserpointer 1 Answer

OnMouseDown doesn't work 1 Answer

Clicking button locks mouse, doesn't activate button. how do I fix this? 0 Answers

Detect mouseDown & mouseUp events on handles in editor 2 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