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 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 hit(my cube whitch represends my ship just bounce for a while on sphere) and i stop presing control button my ship flyes away from planet. I don't know what to do and how i can prevent it. Any help? I'm attaching 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
Add comment · 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
0
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 something else, will often bounce/react which sounds like what you are experiencing when you say "ship flys away from planet". I think you need a way to force/stop on contact with Collider to stop that. Something like

rigidbody.velocity = Vector3.zero;

Edit: converted to Answer

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

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

Both Kinematic and Non-Kinematic behaviours at the same time. 1 Answer

Collision failing on fast moving object 1 Answer

Why Rigidbody collide with wall passes through partially? 0 Answers

How to make Sprite not Bounce on Collision (2D) 6 Answers

Object moves too fast after bouncing off of a moving collider,objects move too fast after bouncing off a moving collider 2 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