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 MadJohny · Mar 03, 2013 at 10:32 AM · javascripttriggersparkour

Wall Running with triggers, how to do it?

alt text I'm making a free running/parkour game like mirror's edge and one of the best ways I can think of is making 3 triggers on the player, one on left, one on right, and one on front of the character, my character is a rigidbody btw, I want to add probably one script for each trigger, to call something like this:

 function OnTriggerEnter (col : Collider)
 {
     if ( col.gameObject.tag == "wall")
     sendMessage ("WallRunRight")
 }

but how do I send a function like this to my main script? and then On my main script I would have like a function o tell what that function does? Or you think it's better this way?

 var MainPlayer : gameobject;
 var WallRunningRight : boolean = false;
 
     function OnTriggerEnter (col : Collider)
     {
         if ( col.gameObject.tag == "wall")
         WallRunningRight = true
     }

and then on function update I would use something like this;

 function update ()
 {
     if (WallRunningRight)
     MainPlayer.rigidbody.useGravity = false; // then I'll add some force to decal down over time, but tell me wich way you think it's better or even if none of these would do a good work
 }


edit: ok it is kinda working I tried the second one but it's giving me some problems, Idk Why but when I jump during left wallrun it goes more far than if I jump while right wallrun, and when I'm in right wall run and pressing "D" to go against wall it jumps to the left as it should, but if I'm on a left wall run and press A against the wall and then jump I jump to the wall instead and that will let me jump multiple time since I don't go away from the wall. Take a look at my scripts please: http://pastebin.com/hFZ20fmH, it's the main script, right wall run script : http://pastebin.com/njk53BXZ and left wallrun script: http://pastebin.com/QntPxR8A

sem título.png (11.2 kB)
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
Best Answer

Answer by MadJohny · Mar 03, 2013 at 03:48 PM

Wow, I'm surprised by myself, I actually did it but if someone can help me in maths like fall from wallrun after a certain time...

edit: Ok I dunno why but when I juump while doing a left wall run I go so much far compared to the right wall run jump, someone please take a look at my scripts: wall run right script: http://pastebin.com/0dxtnR2V wall run left script : http://pastebin.com/aBd9KZFG and the general movement script : http://pastebin.com/zFjCRift

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 RPMonkey · Nov 15, 2015 at 08:42 PM 0
Share

Dude! These 3 sripts are amazing! I've been editing them for the past few days and it works like a charm! You're awesome at coding!

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

10 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

Related Questions

Check which waypoint is closer 1 Answer

Multiple IsTriggerStay check for several game objects from one script 0 Answers

Setting Scroll View Width GUILayout 1 Answer

Need help with setting all items of a specific tag to "inactive" when i die. 1 Answer

Need Help Calling A Trigger Function 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