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
2
Question by user-7337 (google) · Dec 11, 2010 at 07:10 PM · rigidbodyfpscollideladder

Fps Ladder script...

Hello,I am currently just simply using the standard fps controller.I am not a coder(even though I need to be)So I was wondering If I could get a simple ladder script that would move my fps controller up the y axis once I touch(collide) the ladder to work with a standard fps controller. Any feedback is 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
3
Best Answer

Answer by uhahaha · Dec 12, 2010 at 03:22 AM

(1) Attach a box collider in addition to a mesh collider to your ladder object (name it "ladder"). In the Inspecter check the "Is Trigger" property in the Box Collider. It will be used as a trigger, and the following code uses this property. The Mesh Collider prevents the First Person Controller from falling through the ladder.

(2) Create a javascript and copy&paste the code below, and attach the script to the First Person Controller.

(3) I set the slope limit to 85, but you can change that howver you wish.

function OnTriggerEnter (other : Collider) { if(other.gameObject.name == "ladder") { transform.GetComponent(CharacterController).slopeLimit = 85; transform.GetComponent("CharacterMotor").sliding.enabled = false; } }

 function OnTriggerExit (other : Collider) 
 { 
     if(other.gameObject.name == "ladder")
     {
         print("leaving ladder");
         transform.GetComponent(CharacterController).slopeLimit = 45; 
         transform.GetComponent("CharacterMotor").sliding.enabled = true;
     }
 }

You could use OnControllerColliderHit etc instead of OnTrigger functions- it's up to you. This is just one way I came up off the top of my head, and I can imagine various other methods. Hope it helps.

Comment
Add comment · Show 7 · 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 Michael 12 · May 05, 2011 at 01:36 AM 0
Share

Why does this NOT work? I folled it to the letter!!

avatar image Lost_C4 · Dec 20, 2012 at 12:15 AM 0
Share

Nope. This scripts is working.

avatar image inglipX · May 12, 2013 at 10:13 PM 0
Share

Not working at all.

avatar image hike1 · Jun 10, 2013 at 05:21 PM 0
Share

This isn't working in unity 4.1.3f3, worked before though

avatar image hike1 · Jun 16, 2013 at 03:18 AM 0
Share

I tried to convert this to .cs, I get

Assets/scripts/ClimbLadder.cs(14,54): error CS1525: Unexpected symbol )' Assets/scripts/ClimbLadder.cs(22,54): error CS1525: Unexpected symbol )'

         transform.GetComponent<"Character$$anonymous$$otor">().sliding.enabled = true;

using UnityEngine; using System.Collections;

public class ClimbLadder : $$anonymous$$onoBehaviour { //climb_ladder.cs

void OnTriggerEnter ( Collider other ){ if(other.gameObject.name == "ladder") { transform.GetComponent().slopeLimit = 85; //this is line 14 transform.GetComponent<"Character$$anonymous$$otor">().sliding.enabled = false; } }

 void  OnTriggerExit ( Collider other  ){ 
     if(other.gameObject.name == "ladder")
     {
         print("leaving ladder");
         transform.GetComponent<CharacterController>().slopeLimit = 45; 
         transform.GetComponent<"Character$$anonymous$$otor">().sliding.enabled = true;//line 22
     }
 }

}

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to move target when it collides with a bullet 1 Answer

FPS RIGIDBODY PROBLEM 1 Answer

FPS Ladder Script Help(C#) 1 Answer

Object falling through terrain with script 2 Answers

Places to better learn Unity Scripts 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