- Home /
lock local x-translation on rigidbody with ice material
Hi everyone
I'm quite new with unity. I'm working on a basic 3d snowboard game. I am using the ice material on the board so that it can smoothly slide downhill like it would on snow, but I don't want the board to slide to the left or the right (local x-axis). I think there is a simple scripting solution but i can't find it.
Looking forward to the answers
sdp
Answer by XienDev · Dec 15, 2012 at 08:53 AM
Use http://docs.unity3d.com/Documentation/Components/class-PhysicMaterial.html Friction Direction 2, i used it for sliders =)
Thanks man ! That is what i needed, really appreciate your help :)
sdp
Answer by Nidre · Dec 14, 2012 at 08:02 PM
You can use a little script like this to lock it. I have written the code from memory so there could be little mistakes in syntax :)
float lockPos = 0;
void Update()
{
transform.position = new Vector3(lockPos,transform.position.y,transform.position.z);
}
Answer by sdp · Dec 14, 2012 at 08:31 PM
Thanks for the help! But the problem is that it has to lock the translation on the local x-axis and not the global x-axis. So if the board is 90 degrees with the slope, it should stop and if the board is like 45 degrees relative to the slope, it would accelerate forward but not sideways like it normally would.
You can use the same code with the localPosition property then ? just replace position withte localPosition.It should work if understood correctly
Your answer
Follow this Question
Related Questions
snowy environment like this? 1 Answer
Realistic Snow Blender 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
Convert string to material 0 Answers