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 mavii_ege · Feb 17, 2014 at 05:51 AM · collisionunity 2dglitchignore collisions

Unity 2d Collision Problem

My player glitches on other objects. example video;http://www.youtube.com/watch?v=tCmcIdgk8x4

Update İ use Triggers on diamonds all same colors are same rectangle Script pragma strict

 var speed = 3.0; //This Data type is float.
 var jumpSpeed = 50.0;
 var grounded = true;
 var customSkin : GUISkin;
 var textureToDisplay : Texture2D;
 private var score = 0;
 
 function Start () {
   
 }
 
 function Update () 
 {
 
    var z : Vector3 = transform.right * Time.deltaTime * speed;   
    transform.Translate( z);
    
   if (Input.GetButtonDown("Jump"))
   { 
   Jump();
   }
 
 }
 
 function Jump()
 
 {
    if (grounded == true)
    {
   rigidbody2D.AddForce(Vector3.up * jumpSpeed);
   grounded = false;
   }
 }
 function OnCollisionEnter2D(collision : Collision2D) 
 {
   grounded = true;
   
 }
 
 function OnTriggerEnter2D(coin : Collider2D) 
 
 {
  
        // Increment the global score variable declared in the by 1
             // ++ is short hand for currentScore = currentScore + 1;
  score++;
 
 Destroy(coin.gameObject);
            
  
 }
 
 function OnGUI () 
 {   
     GUI.skin = customSkin;
        GUI.Label (Rect (-15, -12, 454 , 129),textureToDisplay);
 
 
 
     
     GUI.Label (Rect (50, 20, 500, 200), score.ToString());    
     
 
 
 }
Comment
Add comment · Show 4
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 robertbu · Feb 17, 2014 at 05:52 AM 0
Share

You don't give us much information to go on. Seeing your script would be helpful. Are you using triggers or colliders for the diamonds? Do you use the same for the rectangle?

avatar image mavii_ege · Feb 17, 2014 at 05:56 AM 0
Share

updated post

avatar image robertbu · Feb 17, 2014 at 06:13 AM 0
Share

Assu$$anonymous$$g this same script is on the rectangle, then it looks like you forgot to turn on the 'isTrigger' property on the collider.

avatar image mavii_ege · Feb 17, 2014 at 06:17 AM 0
Share

i want to solid stop on collision with rectangle, not to take like coin/diamond, is it possible ?

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by robertbu · Feb 17, 2014 at 06:57 AM

The problem is because you are directly manipulating the transform for forward movement. When you do manipulate the transform, you make small 'teleports' forward. Therefore you teleport into the large rectangle and physics pushes you back out.

A fix (not without its own set of issues) is to move the object using the Rigidbody2D instead of manipulating the transform. For example, you can do this instead of the 'transform.Translate()'.

 function FixedUpdate() {
     rigidbody2D.velocity = Vector2(speed, 0);
 }

 
Comment
Add comment · Show 1 · 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
avatar image mavii_ege · Feb 17, 2014 at 07:02 AM 0
Share

thanks fixed the problem for now i should do more search on rigibody and fix the new issues.

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

18 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

Related Questions

Ghost collisions problem: RigidBody player bounces, when moving on platform edges 2 Answers

Ignore collision at the start of the game. 1 Answer

Collider2Ds acting glitchy 0 Answers

Collision gives insane velocity to the character 2 Answers

PolygonCollider2d Use Z Axis 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