• 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
Question by Sebulec · Mar 22, 2014 at 08:37 PM · collisionrigidbodybounceflying

Player bouncing off issue

Hi. I'm doing space shooter game and I have one issue. When I'm flying into my planet(big sphere with sphere collider) for longer then one $$anonymous$$t(my cube w$$anonymous$$tch represends my s$$anonymous$$p just bounce for a w$$anonymous$$le on sphere) and i stop presing control button my s$$anonymous$$p flyes away from planet. I don't know what to do and how i can prevent it. Any help? I'm attac$$anonymous$$ng my scripts from planet and player. Player(has collider and ridgitbody) :

 using UnityEngine;
 using System.Collections;
 
 public class GraczS : MonoBehaviour {
     
     public float speed= 10;
     
     
     
     // Update is called once per frame
     void Update () {
         
 
         float front_w  = Input.GetAxis("Vertical")* speed * Time.deltaTime;
         transform.Translate(Vector3.forward * front_w); 
         float upanddown = Input.GetAxis("UpandDown") * speed * Time.deltaTime;
         transform.Translate(Vector3.up * upanddown );
         float side_w  = Input.GetAxis("Horizontal")* speed * Time.deltaTime;
         transform.Translate(Vector3.right * side_w);
         
 
         
     }
 
 
 }
 

And planet(Only collider)

 using UnityEngine;
 using System.Collections;
 
 public class Ziemia : MonoBehaviour {
     public float predkoscObrotu ;
 
     // Update is called once per frame
     void Update () {
         transform.Rotate(Vector3.up * predkoscObrotu * Time.deltaTime);
     }
 }
 
 
Comment

People who like this

0 Show 5
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 getyour411 · Mar 22, 2014 at 08:47 PM 0
Share

Please format your code properly.

Does your rigidbody toggle gravity on/off depending on whether they are in space/on planet?

avatar image Sebulec · Mar 22, 2014 at 08:55 PM 0
Share

Gravity is turned off. In project every movement is controlled by scripts. Now code is better? Change something? predkoscobrotu in 2. code means rotatespeed

avatar image getyour411 · Mar 22, 2014 at 08:57 PM 0
Share

Are your movement controls, while on the planet, using Vector3.up or something like that? Are they, at contact, stopping all forces from rigidbody?

avatar image Sebulec · Mar 22, 2014 at 09:03 PM 0
Share

I don't think so. If I cant understand You properly( sorry I don't know English on advanced level) nothing changes on collision. I'm just using default options in my scene i have only sphere with planet script abd collider and player with ridgitbody, my player script camera and mouselook script from assets attached to ship so i can rotate it.

avatar image Sebulec · Mar 22, 2014 at 09:11 PM 0
Share

Thank you so much. Please write it as the answer so I can approve it and give you thumb up! Really big: Thank you.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by getyour411 · Mar 22, 2014 at 09:08 PM

I don't use Rigidbodes often, but one that's in motion, upon striking somet$$anonymous$$ng else, will often bounce/react w$$anonymous$$ch sounds like what you are experiencing when you say "s$$anonymous$$p flys away from planet". I t$$anonymous$$nk you need a way to force/stop on contact with Collider to stop that. Somet$$anonymous$$ng like

rigidbody.velocity = Vector3.zero;

Edit: converted to Answer

Comment

People who like this

0 Show 0 · 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.

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

20 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

Related Questions

bounce and roll a die 2 Answers

Collision misses - possibly not bullet through paper! (now with video) 1 Answer

How physical materials affect collision between rigidbodies? 1 Answer

MovePosition messes up my collisions 1 Answer

Both Kinematic and Non-Kinematic behaviours at the same time. 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