Problems, Objects Colliding Wrongly Unity3d

1

I have a problem that I still can not find the solution:

I'm trying to finish a project with Unity, a simple 2D racing game, where the camera looks static from above and objects descend by gravity. This almost complete functionality, the scripts are working properly, the car and Power Up moving as they should, but at the moment the money passes through the car is the problem, rather than colliding and disappearing by adding the score, the car is being dragged with it.

I'm sending two screenshots of Inspector from the car and the money.

Link to the video lesson from this project I'm basing myself.

At the end of this lesson, the author refers to mark Is Kinematic to solve the collision of the objects "car", "money".

    
asked by anonymous 15.11.2015 / 20:54

3 answers

1

Good afternoon Jhonny Summer

I advise you to use OnTriggerEnter2D in case the money does not affect anything in the direction of the car when colliding. When the Trigger is used it does not assign the effects of physics as two bodies colliding = D, I hope it helps, of this - > link

Do not forget, the object that is bound to the script that has the OnTriggerEnter2D method must be with the "On trigger" collator checked.

Any doubts are there.

    
16.11.2015 / 15:22
0

I can not see the Jhonny images but I'll give you a hint considering that your entire system is really based on gravity.

In this case you should have a Rigidbody2D on all your objects. The "mass" attribute of your money object must be too large in order to cause an influence on the cart when it collides, it should already be much lower in PowerUp and therefore can not cause a displacement before the object is destroyed. >

Some things you can check to try to fix it:

1: Compare the values of the attributes of the rigidbody (mainly: "Mass", "Gravity scale" and "Is Kinematic") and try to leave your money object equal to PowerUp.

2: Compare the attributes of the colliders (especially: "Is Trigger") and leave the same money as the PowerUp ...

3: Check how / when the PowerUp is destroyed in his script behavior and if the money has a call to be destroyed too (may be that as it is not being destroyed when colliding it falls on the cart and is there adding the mass and the influence of gravity that the car suffers causing the undesired effect).

    
16.11.2015 / 12:02
0

Try to integrate not only Rigidbody2D but disable the object to be collided and if you have a sprite transaction activate the animator and deactivate the object or destroy it (in this case the destruction is more advised to consume less memory). >     

09.12.2015 / 14:41