match eulerAngle to work angle

Hi,

I have a transform that can only be rotated in 90 degrees.
Now I want to see what direction the y angle matches to the world so I can apply a force in that direction.

Basicly I want to see if Y is pointing up/down/left/right/forward or backward.

Use transform.forward. (or whichever direction is core to you) and you will get a vector based off of the “forward” vector of whereever you are facing. You then apply force in the transform.forward direction.

Isn;t that going to move my object?

I am creating a prefab thats basicly a curve and once the player hits a trigger, it will use the trigger to adjust the camera so that the vertical part object becomes the floor.

I already have this working that the camera auto adjusts itself by simply copying the triggers rotation.
but I still need to change gravity manually with script variables in the inspector and I would like that process to be automatic as well so it will be less work creating a level.

ok, just a bit confused your OP said add force too, but this is doable.

So you want a person or vehicle or whatever to travel along the road and whatever “down” he is, should be his gravity?

BTW, camera direction is also doable by using Vector3.Dot(vehicle.up, Vector3.up) If that value is > 0.5 then vehicle up is closer to vector3.up than anything else. Same can be done with -vehicle.up, right, -right and so on. no triggers needed. :wink:

yep whatever down is should be the gravity.
I am using a riggidbody ball driven with Torque.

So…

funciton gravityDirection : Vector3 = -Vector3.up;
function gravityAmount = 9.8;

function FixedUpdate(){
	var hit : RaycastHit;
	if(Physics.Linecast(transform.positon, transform.position + gravityDirection * gravityAmount)){
		gravityDirection = -hit.normal;
	}
	rigidbody.AddForce(gravityDirection * gravityAmount);
}

?

Ok I can see what youre doing there but it does not seem to work for me, when I replace
-Vector3.up; with Vector3.up; the ball “falls up” but after a few seconds gravity seems to return to normal and the ball falls down again.

Fixed and thanks for the help

private var currentGravDirection 	: Vector3 	= -Vector3.up;
private var gravityAmount 			: float		= 20;

function FixedUpdate()
{
	var hit : RaycastHit;
	if(Physics.Linecast(transform.position, transform.position + currentGravDirection * gravityAmount, hit))
	{
		currentGravDirection = -hit.normal;
		print(-hit.normal);
		Debug.DrawLine (transform.position, hit.point, Color.red);
	}

	rigidbody.AddForce(currentGravDirection * gravityAmount);
}

How can I get a rotation from that normal hit, so I can rotate my camera along?

I tried sending the currentgravity value to my camera script and use
transform.rotation.eulerAngles = direction; with no effect.