check for angles threshold

Hello i am having a problem. i am making a lunar lander like game. So problem is that i want to check the angles of my spaceship when it landed. for example if the angles of my spaceship is greater than 45 degrees both right or left to something happens.
Thanks in advance

Aw come on, we’re all friends here. “something happens” can only mean one thing:

YOU JUST DESTROYED A 100 MEGABUCK LANDER

8165405--1062239--Screen Shot 2022-05-29 at 10.58.16 AM.png

I’m a self-proclaimed lunar lander expert, having made probably 50 different lunar landers over my lifetime.

Many different ways to get what you want.

One way is just checking the .rotation property of your Rigidbody2D, if you are using that and just compare it to 45 or -45.

Another way is using the transform.up shortcut and checking the .y value against the cosine of 45 degrees:

float yup = transform.up.y;

float maxTilt = Mathf.Cos( 45 * Mathf.Deg2Rad);

if (yup < maxTilt)
{
   // destroy the 100 megabuck lander here
}

If you wanna see my favorite version, it’s Jetpack Kurt Space Flight, in full first person 3D on your iPad / Android:

https://www.youtube.com/watch?v=34wbtTIWdDQ

2 Likes

are you looking just to check if MySpaceship is aligned with the terrain?

Thank you my kind friend :slight_smile:

1 Like

Come back and post sometime and make a video of how it plays… every lunar lander is a little different and I’m always in the mood to see variations. Post here and tag me:

https://forum.unity.com/categories/works-in-progress.673/