Script problems

Hey ,

I’m new to unity and I am only just learning to script in Java , so I can’t do much with anything else yet.

My problem:
I want my character(snowboarder) to tilt downhill depending on the steepness of the slope and also stay on the slope because at the moment he’s just bouncing off.
Could someone create a script for this for me to use.Any help would be useful.

Thanks a lot ,
Hawx

UnityScript. Not Java. Not JavaScript.

I just read a topic where someone (PheolixTalon) was doing something similar. Maybe that will give you a good idea.

And rob you of the enjoyment? Never.

one, it’s called javascript. Java and Javascript are extremely different.

Furthermore this is technically ‘unityscript’ which is based on the ECMA standard. ECMAscript is the official name of javascript (since javascript as a name is bastardized so frequently).

The history of why there is both a java and a javascript is fairly convoluted and weird. And you can thank the 90’s for it, when we all listened to the cranberries, drank zima, and VB6 was actually tolerated… ugh.

As for your problem.

You need to get the ground normal at the location. When your player controller does it’s movement checking it should be storing the normal of the ground where you hit.

Now you just rotate player so it’s up vector matches this ground normal.

Your best bet for doing this rotation is since your ‘right’ vector should remain the same (you tilt forward), so cross product the player’s right vector with the ground normal to get a new forward. Then use Quaternion.LookRotation passing in these new forward and the ground normal as up.