• 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 /
  • Help Room /
avatar image
Question by TUTOCF · Feb 13, 2017 at 01:01 AM · rigidbodygravitysphere

Rigidbody doesn't work with my script

Hello, sorry if my English isn't good because I'm French.

I did a script for my player (a sphere) w$$anonymous$$ch I can control it by using a joystick. When I put my script in my sphere, everyt$$anonymous$$ng works perfectly. Then I add a rigidbody as a component to my sphere for the gravity. But the problem is that my sphere doesn't want to fall, and t$$anonymous$$s one is turning around itself quickly... I don't know why...

My script is following :

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerMotor : BaseMotor
 {
     public VirtualJoystick joystick;
     protected override void UpdateMotor()
     {
         // Get the input
         MoveVector = InputDirection();
 
         // Send the input to a filler 
         MoveVector = state.ProcessMotion(MoveVector);
 
         // Move
         Move();
     }
 
     private Vector3 InputDirection()
     {
         Vector3 dir = Vector3.zero;
 
     //    dir.x = Input.GetAxis ("Horizontal"); 
     //    dir.z = Input.GetAxis ("Vertical");
 
         dir.x = joystick.Horizontal();
         dir.z = joystick.Vertical();
 
         if (dir.magnitude > 1)
             dir.Normalize();
         return dir;
     }
 }

When I uncheck "script" in my sphere, everyt$$anonymous$$ng works.alt text

Thank you !

capture.png (446.0 kB)
Comment

People who like this

0 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 karadag · Feb 13, 2017 at 06:59 AM 1
Share

Could you send your rigidbody component screenshot?

avatar image TUTOCF karadag · Feb 13, 2017 at 10:57 AM 0
Share

alt text

Hello, thank you for answering ! You see ? Everything in my Rigidbodt is OK. That's my WalkingState script for the sphere's movement :

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class WalkingState : BaseState { public override Vector3 ProcessMotion (Vector3 input) { return input * motor.Speed; } }

avatar image TUTOCF TUTOCF · Feb 13, 2017 at 11:46 AM 0
Share

No I succeeded to fix it ! In "constraints", check Z in rotation ! But it still doesn't fall.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

110 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 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 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 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 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 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 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

After added a rigidbody in a GameObject, it moves on rotation 2 Answers

Is it possible to change gravity for only one object? 1 Answer

Rigidbody player movement doesn't response to gravity 0 Answers

let rigidbody idle around in space 1 Answer

Move and control a sphere on irregular terrain and keep it on top of that terrain 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