- Home /
Moving skateboard up an incline surface such as a ramp wtc
Hi there, I've just started using Unity recently to produce a skateboading game project with my co-student so please bear with me, as I have minimal coding skills. I have been looking at an issue that Ive had with smoothly translating a boards movement up an incline (a ramp) of a max angle of 90degrees. At the moment we are using a rigid body with an applied force along with a box collider, as stated before our coding skills are still at a novice level so we have minimal code to show you guys sorry. We have been experimenting with javascript and have looked into aspects such as raycasting etc but still no results that come to our standards. We would learn to understand and begin coding from the very start but my co student and I are on a strict timelimit and would just not have enough time to learn all that we would need to start it from scratch. Any help on this issue would be greatly appreciated, thanks.
What is the problem/question you have? Isn't it working with physics or what do you need help with?
Yes it is to do with the rigidbody physics, we want to add a force to the forward movement to our gameobject (skateboard with a box collider) for it to travel over ramps smoothly that have inclining angles up to 90degrees. We have little idea of how to script this so any help on it would be great. However we were able to find a script in c# which has a very similar idea of what we wanted. Unfortunately we are using javascript so we were unable to understand it properly to change and use it.
Answer by iwaldrop · Jan 17, 2013 at 12:01 AM
As long as both the ramp and the board have colliders and rigidbodies then you should just be able to add a force to the board and watch it fly right up the ramp.
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html
function PushBoard()
{
rigidbody.AddForce(Vector3.forward * 10); // replace 10 with whatever force you want to add.
}
function Update() {
//this is the forward speed that will actually happen
var forward$$anonymous$$oveAmount=Input.GetAxis("Vertical")*forwardSpeed;
//actual turn amount
var turnAmount = Input.GetAxis("Horizontal")*turnSpeed;
//rotate the vehicle
transform.Rotate(0,turnAmount,0);
//push the vehicle forward with a force
rigidbody.AddRelativeForce(forward$$anonymous$$oveAmount,0,0);
}
how do you think we could go about putting that piece that you just tiyped up fit in with our movement script still work if possible
Your answer
![](https://koobas.hobune.stream/wayback/20220613091016im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to add force like a "kick" relative to swipe angle? (Skate game) 1 Answer
Character controller or rigidbody? for skateboard 1 Answer
Rigidbody isn't working properly 1 Answer
How to fix/clamp rigidbody dir vector, despite Force dir 1 Answer
How to change velocity of object which move by Rigidbody. 1 Answer