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 logicandchaos · Feb 10, 2017 at 07:32 PM · frictionphysics 2d

[SOLVED] Frictionless space

UPDATE: I solved and finished the game a while ago, my problem was that I was doing the explosions all wrong, my player didn't have the velocity I thought it did. It was being pushed by the expanding collider of my explosion. I made the explosion Collider onsize and that fixed my issue. This was all due to a lack of knowledge of how unity physics work.

Hey I'm making a 2D space shooter, I have my player moving friction-less like I want and collisions with asteroids work, but when the player collides with an explosion the player slows down which is not what I want, the explosion is a circle that expands as the circle expands it pushes the player away, but when the explosion is destroyed the player no longer being pushed slows down, I want the player to keep it's velocity, but when the explosion is expanding and pushing the player the player's velocity does not seem to increase. I am using a physics material that is friction-less and I have tried using add force in OnCollisionEnter and Exit, but it does not seem to work right, I hope someone has a good answer

here is my explosion code:

public class Explosion : MonoBehaviour { CircleCollider2D cc;

 void Start()
 {
     cc = GetComponent<CircleCollider2D>();        
 }

 void Update()
 {
     if (GameManager.gameState != GameManager.GameStates.play)
         return;
     //increase the collider
     cc.radius += Time.deltaTime/2;
     //destroy object after 1.5 seconds
     Destroy(gameObject, 1.5f);
 }

}

Update: Sorry I didn't post my player code because there is nothing in it that slows down the player, also it happens with the asteroids when they hit the explosion as well, the increasing size of the collider is not causing the problem I just tried it with a fixed sized circle, the player and asteroid collisions work fine, it seems as the explosion collider expands it pushes the other objects away but does not effect other object's velocity for some reason..

Update 2: Here is the code I spawn the explosion with:

public class LaserBeam : MonoBehaviour {

 float speed = GameManager.LIGHT_SPEED;
 public Explosion explosion;

 void Start()
 {
     this.GetComponent<Rigidbody2D>().AddForce(transform.up * speed);
 }

 void Update()
 {
     if (GameManager.gameState != GameManager.GameStates.play)
         return;
     //destroy object after 1 second
     Destroy(gameObject, 1);
 }
 void OnCollisionEnter2D(Collision2D col)
 {
     if (GameManager.gameState != GameManager.GameStates.play)
         return;
     //destroy target
     if (col.gameObject.tag == "Asteroid") //if (col.gameObject.tag != "Player")
     {
         Vector2 size = col.transform.localScale*4;
         Destroy(col.gameObject);
         //create explosion
         explosion = Instantiate<Explosion>(explosion);            
         explosion.transform.position = col.transform.position;
         explosion.transform.localScale = size;
         //destroy object
         Destroy(gameObject);
         GameManager.playerScore += 50;
     }
 }

}

also my objects all have a 2d physics material with 0 friction and .333 bounciness

Here is the ridgidbody for my player: alt text

playerrb.png (69.4 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 TheFish657 · Feb 10, 2017 at 09:30 PM 0
Share

Can I see the player code?

avatar image FortisVenaliter · Feb 10, 2017 at 10:00 PM 0
Share

Can you post a screenshot of the rigidbody's inspector as well?

avatar image logicandchaos FortisVenaliter · Mar 24, 2017 at 03:52 PM 0
Share

sorry for the late reply but I just posted it

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by logicandchaos · Mar 24, 2017 at 03:23 PM

Hey I'm still having trouble with my game, no matter what I do my player object slows down a little while after colliding with an explosion, the player does not slow down after any other collision or when I move and I have no code that slows down my player, I don't know why the player slows down, it's really frustrating, in any other game engine I used not using friction was very easy, you just don't add it.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

apply z-axis friction on 2d game 0 Answers

Trigger problem on devices 0 Answers

Friction affects ball's direction after collision 0 Answers

Difference in friction between objects with Rigidbody and without 0 Answers

(3D Mode) 2D Friction 0 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