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
0
Question by NewLife Prod. · Jan 05, 2015 at 11:58 AM · c#playerjump

how to make player jump from clicking a box collider?

Hi I need help with making my player jump by clicking another object. So, I have a script on my player that says when I click anywhere on the screen it will jump. What I'm trying to do is make a split screen where there are two box colliders and one controls player 1 and the other controls player two. I don't know how to find the player game object if I click the box to make my player jump. May someone help me figure this out please?

I'm scripting in csharp by the way... Thanks ahead of time if anyone knows the answer.

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 Codessaurus · Jan 06, 2015 at 11:01 AM 0
Share

If you run into trouble I can try to help you. I'am no expert but my first project was something like that, I know how sometimes little things are so frustrating :b

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Berenger · Jan 05, 2015 at 02:24 PM

There is several ways to do such a thing :

  • Use GameObject.Find(player's name) => slow.

  • Use a different tag on each one and then use FindGameObjectWithTag.

  • Declare a public variable in the script that receive the click, then assign the player to it.

  • In the player script's update, check for Input.GetMouseButtonDown, the check the position of the mouse compared to to half the screen width.

Then jump.

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
0

Answer by Codessaurus · Jan 05, 2015 at 02:59 PM

When you are creating your player instances you should instanciate your prefab for the box controller with a script (for example: BoxControllerScript), where you should store your players name.

Then create a script for the player aswell, and inside the update function check for mouse clicks. When there is a mouse click use a raycast to get the object you are pointing at.

At this point you get the gameobject that you pointed at, check if it has the BoxControllerScript and if the player name match with the stored one, if it does, just jump.

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
0

Answer by NewLife Prod. · Jan 05, 2015 at 08:28 PM

Thanks, I'll try it out...

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Dash in movement direction, not in forward direction 0 Answers

How do I get my jump animation to work? 1 Answer

Jump Function C# hassle! 0 Answers

time counter in scripting 2 Answers

Jump Further When Key Is Held Down 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