Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Madswint · Nov 20, 2013 at 04:55 PM · movementplayerrange

Need help on making player move towards gameobject, if clicked

Okay so I'm making a fishing script around the same as in Runescape. Basicly you click on the fishing spot and it moves towards it, when you are in range, it will start fishing. I know how to do this, but I do not know the commands since I am 'new' to java scripting. (I would prefer if you helped me in Javascript since that is what I am learning and it's going quite well).

Also I'm not sure if using tags to find the player will do, since it's going to be multiplayer and all players will move towards the fishing spot if someone clicks on it, wont they?

My question is, how do I make the character, go so he is in range of the fishing spot (gameobject in this case)?

 function Update () {
 
 
 
 if (Input.GetKeyDown("Mouse 0"))
 //player walk till he is in range
 
 -
 //then activate function that has animation and the fishing script I'll figure out
 }

I have something like this atm, can be done in a better way probably, but yeah. Any help 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

· Add your reply
  • Sort: 
avatar image
0

Answer by kubci98 · Nov 20, 2013 at 04:57 PM

Maybe Vector3.Lerp could work.

Comment
Add comment · Show 12 · 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 Madswint · Nov 20, 2013 at 04:59 PM 0
Share

I'll take a look at that! Thanks.

avatar image kubci98 · Nov 20, 2013 at 05:04 PM 0
Share

You can also use $$anonymous$$oveTowards or SmoothDamp. $$anonymous$$oveTowards Documentation, SmoothDamp Documentation. All these will just move you from one place to another smoothly, if you want players to move around obstacles, you need AI pathfinding (if you don't have Unity Pro, you will need to make your own pathfinding). Unity Pro pathfinding, AI tutorials after 1.32 (a little more difficult way, you might need watch also previous tutorials (1.1 - 1.8))

avatar image kubci98 · Nov 20, 2013 at 05:14 PM 0
Share

Also have look at this - you can use it to find out where player clicked: Input.$$anonymous$$ousePosition

avatar image Madswint · Nov 20, 2013 at 05:19 PM 0
Share

You're my god, thank you, I can use this for so many scripts.

avatar image christinam · Nov 20, 2013 at 05:21 PM 0
Share

Are you still looking for a way to distinguish your player from the other players?

Show more comments

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

19 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

Related Questions

Unity Enemy Range detection 3 Answers

Player Going through colliders 1 Answer

Orbit player around center point 1 Answer

Character movement range in strategy game. 2 Answers

Implement moveSpeed to this object script? 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