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 MasonLCook · Jun 02, 2013 at 07:17 AM · physicscontrollercharacter controllersphererigid body

How To Improve my Rigid Body Sphere Character Controller

Hello All, I'm currently working on making a simple game that uses the a sphere with a rigid body as the character. I use a rigid body sphere because I want to make some mini-games using Unity's Physics. Unfortunately I can't seem to find any built in one so I wrote my own.

Here are my problems: 1. The controls are unresponsive, it takes a while for your character to change velocity to a different direction. 2. I haven't been able to find a way to cap the max speed. 3. Once again, controls are VERY Unresponsive. Any Ideas?

Here is my current code. // Include Unity Assets using UnityEngine; using System.Collections;

 // Declare our class 
 public class launchRampTrigger : MonoBehaviour
 {
     // Imnspector Variables
     public GameObject player;
     public float moveSpeed;
     
     // Use this for initialization
     void Start()
     {
     }
 
     // Update is called once per frame
     void FixedUpdate()
     {
         // Store our axis numbers for movement
         float horizontalAxis = Input.GetAxis("Horizontal");
         float verticalAxis = Input.GetAxis("Vertical");
 
         ////////////////////////////
         // Move Player
         rigidbody.AddForce (Vector3.forward * moveSpeed *  Time.deltaTime * horizontalAxis);
         rigidbody.AddForce (Vector3.right * -moveSpeed *  Time.deltaTime * verticalAxis);
         
     }
 }

And sorry the file has a weird name, I forgot to change it's name ha..

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 BlackWingsCorp · Jun 02, 2013 at 10:21 AM

I have a couple of suggestion: 1)use something like this: public class NewBehaviourScript : MonoBehaviour {

     public GameObject player;
     public float speed = 20;
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
     if(Input.GetKey(KeyCode.UpArrow)){
             player.transform.position = transform.forward * speed * Time.deltaTime;
     }
 }
 }
 
 //use the same technique for the rest of the directions. change the value of "speed" to change the speed


2)add the first person controller component to the sphere. then change the camera, speed, etc in the inspector view

Hope it helps

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 robertbu · Jun 03, 2013 at 06:01 AM

Object turn faster:

  • Increase the drag (0 by default) in the Rigidbody, and increase the force applied each frame. Increasing the drag will cause the existing velocity to decay faster and the new velocity to be more "meaningful."

  • You can "turn" the velocity instead of adding force. The object will then turn instantly.

To restrict speed:

  • You can scale the force applied each frame so that at higher speeds, no force is applied.

  • You can limit the velocity directly:


     if (rigidbody.velocity.magnitude > some_value)
             rigidbody.velocity = rigodbody.velocity.normalized * some_value;
    
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

16 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 avatar image avatar image

Related Questions

Unity 4 to 5 Character Controller Issue 1 Answer

Character Controller problems with a space ship 1 Answer

Do character controllers work with dynamic gravity? 1 Answer

How to detect angles of walls? 1 Answer

Gun collision problem 3 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