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 davidflynn2 · Oct 05, 2012 at 04:24 PM · c#jetpack

Making a Jetpack

I am trying to make is so that my player has like a jet boost to push him up in the air when you press the Left Shift key.

I have tried all the following codes for no results.

This One

 if ( Input.GetKey("v") )
  constantForce.force = 8000 * Vector3.up;
 else 
  constantForce.force = Vector3.zero;

This One:

 var boostFactor : float = 100; // or whatever
  
 function Update () {
  
 if ( Input.GetKey("left shift") ) {
  target.rigidbody.velocity += target.transform.up * boostFactor;
 }

This One:

 if ( jetpackOn ) 
  localGravity += jetpackAcceleration * Time.deltaTIme;
 else
   localGravity -= 9.81 * Time.deltaTime;
  
 charactercontroller.Move( Vector3( x, localGravity, z ) );

None of these even make my character leave the ground. I have just the starndard character controller on it using the thirdperson controller and i have added a ridgidbody.

Comment
Add comment · Show 3
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 Mander · Oct 05, 2012 at 04:41 PM 0
Share

Input.GetButton

avatar image davidflynn2 · Oct 05, 2012 at 05:19 PM 0
Share

still never makes a difference.

avatar image Kiloblargh · Nov 20, 2012 at 04:53 PM 0
Share

A jetpack; you mean like- the one Lerpz has in the first tutorial? Just sayin'...

3 Replies

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

Answer by programmrzinc · Oct 05, 2012 at 05:32 PM

Use this code Instead

 var speed : float = 6.0;
 var jumpSpeed : float = 8.0;
 var gravity : float = 20.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 *= speed;
         
         if (Input.GetButton (KeyCode.V)) {
             moveDirection.y = jumpSpeed;
         }
     }
 
     // Apply gravity
     moveDirection.y -= gravity * Time.deltaTime;
     
     // Move the controller
     controller.Move(moveDirection * Time.deltaTime);
 }
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 Mr_Manza · Jun 30, 2014 at 08:08 AM 0
Share

what is character controller? component wise is it something I need to make like a player? or is this how I enter the script? new to this sorry

avatar image
0

Answer by slkjdfv · Oct 05, 2012 at 05:29 PM

Does your character have a rigidbody attached? you can't add forces to an object unless said object has a rigidbody attached. And IF it does have a rigid body attached make sure isKinimatic is unchecked. After all that try using rigidbody.addforce.

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 Mander · Oct 05, 2012 at 05:34 PM

ok here. look using the character controller. u may use a very useful script from the documentation.

movement script

here u can find how to "Jump" but u can modify it to ur convenience. give it a try.

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

Multiple Cars not working 1 Answer

Converting to C# 1 Answer

Convert js to c# 2 Answers

Why does my slide out menu not work when i translate from JS to C#? 1 Answer

Lightning Script Js To C# Conversion errors 2 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