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 Ultrasnowfire · Apr 06, 2013 at 04:20 AM · rigidbodyfpswallsclimbing

RigidbodyFPSWalker climbing walls

Hey,

I am using a rigidbody fps controller with this script : http://wiki.unity3d.com/index.php?title=RigidbodyFPSWalker and it seems to be able to climb up walls if you hold the w key, face the wall front on and spam the space bar. Does anybody know how I could fix this? Or is there a better rigidbody fps Controller that i could use? I need it to be rigidbody because it needs to interact with other rigidbodies and i need to apply Physics.gravity to it.

Thnx in advance.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by el_rolas · Apr 07, 2013 at 01:49 AM

ok there are two simple solutions, you could change you rigidbody movement for character controller movement (see character controller in script reference), and you can keep the rigidbody

Character Controller

Or you could set cubes near the walls, just turn off the renderer, for invisible cubes, is no the best option but that could help.

feel free to send me private message if you need more help.

Comment
Add comment · Show 8 · 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 Ultrasnowfire · Apr 09, 2013 at 03:22 AM 0
Share

Hey, the character controller thing worked well but it stops the ability to push around cubes. Do you know how i could fix that?

avatar image el_rolas · Apr 09, 2013 at 03:34 AM 0
Share

did you kept the rigid body?, also you can fake this, by tigger, you can deactive the rigidbody gravity, and activate it again when you hit the trigger, you set the trigger near a box for example, and then you can move the box

avatar image Ultrasnowfire · Apr 09, 2013 at 03:43 AM 0
Share

I kept the rigidbody, also it doesn't use rigidbody gravity. I need this functionality so that the character can walk on walls and the roof

avatar image el_rolas · Apr 09, 2013 at 03:54 AM 0
Share

i dont understand

avatar image Ultrasnowfire · Apr 09, 2013 at 03:56 AM 0
Share

I kept the rigidbody on the character but it doesn't use the physics.gravity when it has Character Controller on it aswell

Show more comments
avatar image
0

Answer by rakeshmalik91 · Feb 21, 2015 at 12:36 AM

As a solution I have made a little change in RigidbodyFPSWalker. Actually copied some code in it from CharacterMotor.

 #pragma strict
 
 var speed = 10.0;
 var gravity = 10.0;
 var maxVelocityChange = 10.0;
 var canJump = true;
 var jumpHeight = 2.0;
 var jumpPerpAmount = 0.5;
 
 private var grounded = false;
 private var groundNormal: Vector3;
 private var controller : CharacterController;
 private var tooSteep: boolean = false;
  
 @script RequireComponent(Rigidbody, CapsuleCollider, CharacterController)
  
 function Awake () {
     rigidbody.freezeRotation = true;
     //rigidbody.useGravity = false;
     controller = GetComponent (CharacterController);
 }
  
 function FixedUpdate () {
     if (grounded) {
         if(!tooSteep) {
             // Calculate how fast we should be moving
             var targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
             targetVelocity = transform.TransformDirection(targetVelocity);
             targetVelocity *= speed;
 
             // Apply a force that attempts to reach our target velocity
             var velocity = rigidbody.velocity;
             var velocityChange = (targetVelocity - velocity);
             velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange);
             velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange);
             velocityChange.y = 0;
             rigidbody.AddForce(velocityChange, ForceMode.VelocityChange);
         }
         
         // Jump
         if (canJump && Input.GetButton("Jump")) {
             rigidbody.velocity = Vector3(velocity.x, 0, velocity.z) + Vector3.Lerp(Vector3(0, 1, 0), groundNormal, jumpPerpAmount) * CalculateJumpVerticalSpeed();
         }
     }
  
     // We apply gravity manually for more tuning control
     rigidbody.AddForce(Vector3 (0, -gravity * rigidbody.mass, 0));
  
     grounded = false;
     groundNormal = Vector3(0, 0, 0);
     tooSteep = true;
 }
  
 function OnCollisionStay (collision : Collision) {
     for(var contact: ContactPoint in collision.contacts) {
         groundNormal += contact.normal;
         if(contact.normal.y > Mathf.Cos(controller.slopeLimit * Mathf.Deg2Rad)) {
             tooSteep = false;
         }
     }
     if(collision.contacts.Length > 0) {
         groundNormal /= collision.contacts.Length;
     }
     grounded = true;
 }
  
 function CalculateJumpVerticalSpeed () {
     // From the jump height and gravity we deduce the upwards speed 
     // for the character to reach at the apex.
     return Mathf.Sqrt(2 * jumpHeight * gravity);
 }

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

13 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

Related Questions

Importing a wall with doorway into unity, but rigid body/collider is affecting the door way (empty gap) 1 Answer

RigidBody.MovePosition seems jerky in movement 0 Answers

Distance From & CrossHair 0 Answers

OnTriggerEnter not functioning 0 Answers

Enemy death help 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