Pins Shaking

cud_s08_counting_upright_objects

#1

There was a discussion posted on here before that had the same problem but was closed. I tried what they suggested but still my pins shake. The position of the pins rapidly change and then stop after a certain point. Has anyone experienced this? I just can’t get it to work and it’s been frustrating me. Below are the components I have for a bowling pin:

image

image

image

Am I missing something?


#2

I too am having this issue and was hoping it would be explained by the end of the section, but it was not. I think we could put a cut off timer in there where if it takes longer than 10 seconds to decide how many are standing it just moves on, but that wouldn’t be as accurate.


#3

This video explains what happens:

basically, the pins are always falling down, a possible fix for that is to reduce the Physics sleep threshold in the Physics manager:
https://docs.unity3d.com/Manual/class-PhysicsManager.html


#4

I tried reducing the Physics sleep threshold and also the bouncing threshold but still the pins shake. Does anyone have a unity package (that is running as should) I can import so I can compare what is going on with my project?

In the mean time, I may have to work around it with something like Benjamin posted.


#5

How about changing the collision detection mode from the pins to continuous and set the floor to static?


#6

I changed the pins to continuous detection mode and it still shakes. How do I set the floor to static? From what I understand, mesh colliders without a rigidbody are static, and the floor doesn’t have a mesh collider. This is what I have set for my floor:

The method IsStanding will alternate between true and false (more so false) but will always end up returning false. This happens because the pin’s position and rotation is constantly moving, hence the shaking of the pin. I can’t find a way to stop the pins from shaking.


#7

Sorry, I can’t think of other reason for it to be wobbling, perhaps you could try one more thing, put a empty gameobject in the scene and make everything child of it, and then set it’s scale to 0.01 in every axis and then unchild everything again. This should divide the scale of everything by 100.

Static colliders are the ones that don’t have a rigidbody or that is market as static in the top of the inspector


#8

I created a parent object and made all objects in the scene a child of it. I then set each axis scale to 0.01 and unchilded each object but still the pins wobble. I honestly don’t know what is going on. I moved onto the TileVania section of this course for the meantime. Thanks for helping me with this weird bug in my project, I really appreciate it.


#9

Have you tried to adjust the y coordinates for the renew pins method?
Instantiate(PinSet, new Vector3(0, 1.1f, 18.29f), Quaternion.identity)
It took a while to get it right but that solved the wobbling issue. I am using 1 world unit = 1 meter. I am not sure if that makes a difference with your game. You can try to adjust the time when the pins are lowered in the animation. I have it set at 10 secs. If I tried it sooner or later the pins did wobble. I see that your rigidbody collision detection is set to discrete try using continuous dynamic. I am also using a physics material on the bowling lane.


#10

I have exactly the same issue with the pins shaking.

I moved the camer follow script into FixedUpdate() which visually stops the pins shaking but the tiltInX and tiltInY valuse still increase when the pins are standing still which results in the values exceeding the threshold and the code reporting that the pin has fallen over, so frustrating…

I have treied everything mentioned on this post and nothing works. I may just ditch this project and move onto the next one.

;-/


#11

This has been bugging me for ages too, but I may have stumbled upon a workaround that will at the very least allow mw to complete the Bowlmaster lesson. This is by no means elegant, but it seems to be working for me.

So, what was happening for me was, the tilt values were increasing whilst the pins were stationary due to the dreaded shake/jitter, they were going up to ± 9 in most cases which exceeded the threshold of 3 and reported a fallen pin. I tried increasing the threshold to 12, but I was also getting a random tilt value in both X & Z of 359.0000, and this would happen only once per pin? and was always 359?

So what I did was to increase my threshold to 50, I figure if a pin has fallen over then the tilt values would be more than 50 anyway and it is sufficiently high enough to deal with the ±9 tilt values from the shaking.

I also added another test on the tilt values to check they were < 350, that eliminates the false return from the 359 value, and if they were then I continue with the normal check. I also had to remove the Mathf.Abs() also to get it to work.

Like I said, not elegant, and I don’t fully understand why it’s working for me, but it’s allowing me to mitigate the shaking and continue with the lesson.

public bool IsStanding()
{
    Vector3 rotationInEuler = transform.rotation.eulerAngles;
    //float tiltInX = Mathf.Abs(rotationInEuler.x);
    //float tiltInZ = Mathf.Abs(rotationInEuler.z);

    float tiltInX = rotationInEuler.x;
    float tiltInZ = rotationInEuler.z;
    if (tiltInX < 350 && tiltInZ < 350)
    {
        if (tiltInX < standingThreshold && tiltInZ < standingThreshold)
        {
            print(name + " Stading Tall!!!");
            return true;
        }
        else
        {
            print(name + " Fell Over!!! <<<<<<<<<<<<<<<<<<<<<<<<");
            return false;
        }
    }
   

    return true;
}

#12

Hi Pwel,
This is what I have for the IsStanding method. This code was from another post. I made a few adjustments but this is working for my game. The majority of the issues that I was having was what I stated earlier. I am glad to see that you are trying to get the game to work. FYI unit testing is fine for individual classes but Ben has not accounted for how the scoring system works between the classes. I finally have mine working I had to make changes to the score display class and the pin counter class. I am learning how to work with blender because I need to make a gutter lane. For the first 3d game Ben has left us to figure out how to finish it. I think a lot of people have just by passed the bowl master game.

    float tiltX = (transform.eulerAngles.x < 180f) ? transform.eulerAngles.x : 360 - transform.eulerAngles.x;
    float tiltZ = (transform.eulerAngles.z < 180f) ? transform.eulerAngles.z : 360 - transform.eulerAngles.z;

    if (tiltX > standingThreshold && tiltZ > standingThreshold)
    { return false; }
    else
    { return true; }

#13

I haven’t got to the renew pins method because when I came across the wobbling issue I stopped to focus on fixing that. I only set up a floor swiper animation (6 seconds) but not a pin setter. I did set my rigidbody collision detection to continuous dynamic though for future reference.


#14

This did work in that it did return the correct state of the pin, whether it was standing or not. So in that matter it does work correct. However, the wobbling still persists. Do the pins still wobble for you?


#15

This worked as well but like Pwels solution, the pins still wobble, otherwise I would mark either as a solution. I skipped this lesson and moved onto the TileVania lesson when I ran into this problem. I’m more into 2D so I didn’t mind. This bowling game was my first venture into 3D so I figured I’d come back to it.


#16

I am not sure what other suggestions I can provide. I do not have any pins wobbling either by them being tidied or reset;


#17

try and restore the gravity to normal or something like -20