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 Aurelio_hl2 · May 21, 2013 at 01:05 AM · characterrundouble jumpfallelevator

character controller fall on elevator -help-

the elevator is simple, collider that rises and falls, for an animation. the problem is that when I go to the elevator, the character controller falls to move the elevator up. How achieving the . Character controller. Up by elevators without falling? this is the code with the problem:

 #pragma strict
  
     var x :int = 1;
     var controller:CharacterController = null;
     var rapides : float = 6.0;
     var gravedad : float = 20.0;
     var velocidadSalto : float = 8.0;
     var corriendo = false;
     var tiempo : float = 0.0;
            
     private var moveDirection : Vector3 = Vector3.zero;
 
     function Update()
     {
     var controller : CharacterController = GetComponent(CharacterController);
     if (controller.isGrounded) {
     // We are grounded, so recalculate
     // move direction directly from axes
     moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
     Input.GetAxis("Vertical"));
     moveDirection = transform.TransformDirection(moveDirection);
     moveDirection *= rapides;
     }
     //
     if(!(x<=0)&&Input.GetButtonDown("Jump")) {
     //
     moveDirection.y = velocidadSalto;
     x--;
     }
     if(controller.isGrounded) {
     x = 1;
     }
     // 
    if (Input.GetButtonDown("Run")) {
    rapides = 9.0;
    corriendo = true;
    }
    else if (Input.GetButtonUp("Run")) {
    rapides = 6.0;
    corriendo = false;
    }
      if(corriendo)
      {
      tiempo += Time.deltaTime;
      }
    if(tiempo >= 7)
    {
    corriendo = false;
    rapides = 7;
    tiempo = 0;
    }
 
 
     // Apply gravity
     moveDirection.y -= gravedad * Time.deltaTime;
      
     // Move the controller 
     controller.Move(moveDirection * Time.deltaTime);
     } 
  ///////////////////////////////////////////////////////////////////  
Comment
Add comment · Show 9
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 sparkzbarca · May 21, 2013 at 01:06 AM 0
Share

what do you mean it falls without even rising a little.

Please rephrase your question.

avatar image Aurelio_hl2 · May 21, 2013 at 01:17 AM 0
Share

ready, my idea to climb without falling, when the elevator starts to rise, the character controller does not rise.

avatar image sparkzbarca · May 21, 2013 at 01:27 AM 0
Share

need to see the elevator code. Does the elevator have a collider attached?

if so how is it attached? it should I guess be a box or plane bottom.

is it a rigidbody or simply a collider?

avatar image Aurelio_hl2 · May 21, 2013 at 01:37 AM 0
Share

the elevator is a simple collider, controlled by an animation, does not contain any scrip, only loop; up and down.

avatar image sparkzbarca · May 21, 2013 at 01:38 AM 0
Share

did you enable physics during animation?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Aurelio_hl2 · Jun 07, 2013 at 06:17 PM

I solved my problem with this.

this works on platforms: horizontal, vertical, rotating, diagonal, up and down, animated, everything.

not affect physics, no bounce, no fall. does not affect the performance.

create a new java script with this. added a new tag. -> "movim"

add this script to your character controller, or Rigidbody.

     #pragma strict
     //for Character Controller, Rigidbody, collider or more.
     //you can modify *movim* for what you want.
     var dentro : boolean = false;
     public var scala : float = 1.0000;
      
     function Start () {
     dentro = false;
     }
     function OnTriggerStay ( plataformas : Collider ){
     if(!(dentro) && plataformas.gameObject.tag == "movim"){
     this.transform.parent = plataformas.transform.parent;
     dentro = true;
     //Debug.Log ("In");
     }
     }
     function OnTriggerExit ( plataformas : Collider){
     if(plataformas.gameObject.tag == "movim"){
     this.transform.parent = null;
     dentro = false;
     transform.localScale = new Vector3( scala, scala, scala);
     //Debug.Log ("out");
     }
     }

   

alt text

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

14 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

Related Questions

how can i let my player move converse? 0 Answers

How to make the character run in Unity with Kinect? 2 Answers

When I build and run my game my character and objects do not appear in the finished game 1 Answer

How to make a character stop going through the terrain? 0 Answers

Achieved Prone & Crouch, but there is a little question in my mind. (Character Controller) 0 Answers


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