Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
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) which I can control it by using a joystick. When I put my script in my sphere, everything 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 this 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, everything works.alt text

Thank you !

capture.png (446.0 kB)
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 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 O$$anonymous$$. 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 Process$$anonymous$$otion (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.

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

How can I turn a sphere with the mouse while using normal controls to move it? 0 Answers

Rigidbody player movement doesn't response to gravity 0 Answers

let rigidbody idle around in space 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