Console returning as many false and true and pins shaking

Here is my code which returns false and true at the same time and the pins are shaking, I can’t figure out how to get this to behave.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pin : MonoBehaviour {

	//this value is overridden by any change made in the inspector
	public float standingThreshold = 3f;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		print (name + IsStanding());
	}

	public bool IsStanding(){
		Vector3 rotationInEuler =  transform.rotation.eulerAngles;

		float tiltInX = Mathf.Abs(rotationInEuler.x); 
		float tiltInZ = Mathf.Abs(rotationInEuler.z); 

		//print (tiltInX + " " + tiltInZ);
		if (tiltInX < standingThreshold && tiltInZ < standingThreshold) {
			return true;
		} else {
			return false;
		}
		//return true;
	}
}

OK I see why it’s returning false and true as when it shakes in the negative it reports 359 which would make it greater than the threshhold value no matter what. I guess I need to figure out how to get these pins to stop shaking.

Turning off gravity on the pins made them stop shaking

This also happened to me but what to do after that? why do we need to manage the gravity when the lessons didn’t?

I had a lot of trouble with this game and lost faith in unity’s physics engine as a result but I’m sure if I just slow down and tinker I could get it to work. But this did make me buy the unreal engine course to see if their physics engine was any better.

Yeah similar question to @Krimzon

Why didn’t Ben require to turn gravity off but we need to do it to stop the pins shaking?
Did you find any alternative way?

Hi there!

Unity uses NVIDIA PhysX physics engine so it’s really, really good. Strange behavior, in this case, is not Unity Engine fault but this messy section.

As I said in another topic the main problem of Bowlmaster game is overscaled gamespace. Ben has giant 38m height pins which weight only 1,53 kg each. His bowling lane has 2km length. So this is the main reason for the strange behavior. As if it’s not enough bowling pin 3d model was not prepared properly…

So don’t turn gravity off but rebuilt your gamespace using correct scale (1 unity unit = 1 meter). Use correct objects mass, main gravity, use another pin 3d model if you want etc. Also change “standingThreshold” value to something around 30, because 3-degree tilt doesn’t mean that pin has fallen.

In my case, it works perfect and I don’t have any issues with strange gravitation, drag etc. I recommend using some low-friction physic material on the bowling lane too as in real life :wink:

Cheers!

3 Likes

Thank you that’s encouraging. I will keep that all in mind when tweaking while working which I will declare as public float twirking = tweaking * working * time.deltatime * take care;

@Veronica_Zemenovich,

I believe the root of the problem is what Patryk is explaining, but also take a look at this solution here:

It was approved by Ben and is working nice on my project.

2 Likes

I’m going to mark this post solved but only because I don’t want to make a bowling game but I will refer to this post for answers once I get my sandbox developed as I am interested in getting physics behaving like the third rock from the sun
[solved]

Thank you, it definitely solved!

Changing scale to 1 world unit = 1m solved shaking and missing shadows. Just one additional thing, as I scaled almost everything down by 100, launching ball sends it flying with unimaginable speed, so had to change code a bit as well in DragEnd method.

float launchSpeedX = ((dragEnd.x - dragStart.x)/100) / dragTime;
float launchSpeedZ = ((dragEnd.y - dragStart.y)/100) / dragTime;

Privacy & Terms