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 mrTallents · Feb 07, 2012 at 03:43 PM · physicsgravityfirst-person-controllerfps controller

Affecting FPS controller/Character Motor physics with game object

Hi

Thanks for taking the time to check my question. Im making an FPS shooter (for a uni project).

Objective: When running into a particular game object, I want to trigger a launch which sends my player into the sky, whilst continuing forwards in the direction of travel and landing back on the ground a distance ahead of the original position, kind of like a catapult or a gravity lift i guess.

Attempts: I have looked at the lerpz tutorial and understand how that work with that controller, but i cant figure out the character motor.

I have the below script working on a rigid body, e.g. bullets, but its not affecting the player, because its not a rigidbody. I have tried putting a rigidbody on the player and turning off gravity, but still no affect.

Can anyone tell me about controller collider? This might be an option but im not quite sure how to work it! Or how to link with character motor.

Please help if you can? Many Thanks Nick

 //----jumppad.js----
  
 var jumpAngle:Vector3;
 
 var jumpMagnitude:float=1.0;
  
 function OnTriggerEnter (entity: Collider)
 
 {
 
     //Make sure the triggering entity has a rigidbody before we try to access it!
      if(entity.rigidbody)
      {
         print("hit the booster");
         //Apply the force
          entity.rigidbody.AddForce(jumpAngle*jumpMagnitude);
      }
  }
  
 function OnDrawGizmosSelected()
 
 {
 
 //Draw a gizmo in the editor to visualise the jump anglec
 
  Gizmos.color = Color.red;
 
 Gizmos.DrawRay (transform.position, jumpAngle*jumpMagnitude);
 
 }
  
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

Answer by Bunny83 · Feb 07, 2012 at 03:58 PM

The problem is that the CharacterController comes with it's own movement calculations. No physics are involved here. The CharacterController is meant for objects that shouldn't be affected by other objects so you have a nice movement control of your player. However, you can of course add this "jump acceleration" manually. I don't use the CharacterMotor scripts that comes with Unity so i can't tell you where you have to add it, but it should also have some kind of velocity (in most examples it was called moveDirection).

If you want the player to be a real physics object, don't use the CharacterController and switch over to a rigidbody. You should think twice before you decide. The movement has to be handled differently so you can use the CharacterMotor script.

There are some scripts to control a rigidbody in the UnifyCommunity Wiki.

edit
You should read the CharacterController manual to understand what it was made for. If you want direct control of the player you should keep the CharacterController and just add the jump-pad function.

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 mrTallents · Feb 07, 2012 at 05:44 PM 0
Share

Wow i have just found some really cool control scripts on there! Im fairly new to this (as you may tell) but not entirely sure why I havent come across unify yet so thanks for the heads up on that, what a great site.

Thanks for your response, our characters do need to be affected by other objects (probably starting with the most ambitious) so I think i may look down the rigidbody route but will also take a closer look at the controller manual too.

Thanks again

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

gravity doesnt seem to effect my first person controller....help! 1 Answer

Movement on a tube 1 Answer

Rigidbody ball physics 1 Answer

Object affected by gravity freezes after it comes to rest 1 Answer

Need help on my script to calculate gravity for a mass 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