Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / [Zotoaster] Bicycle Physics

Author
Message
Commander in Chief
18
Years of Service
User Offline
Joined: 15th Apr 2006
Location: Carbondale, PA, USA
Posted: 26th Jun 2007 17:12
Alright, I'm using Zotoaster's physics that can be found here:

http://forum.thegamecreators.com/?m=forum_view&t=68873&b=7

They were originally made for a hovercraft vehicle, but in the tutorial he stated that you could change some parts to make it less spinny. Here is the equation that is used:
Position = Position + Velocity

Here is the equation that I want to use:
Position = Position + (Direction * Speed).

I tinkered around with variables and got that equation exactly. But the way he set up the variables is most of them used a type (vector). The Direction variable (MDir) is a vector, and the Speed variable (Speed) is a float. Therefore they are not compatible and cannot compile.

How would I accomplish all of this?

---PlasmaArts---
www.plasmaarts.co.nr - www.plasmaarts-games.co.nr
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 26th Jun 2007 22:14
Well I'm not an expert at all on physics and I this might not be right but pretty sure it is.
Speed is a Scalar quantity, meaning it only has a magnatude. Velocity is a Vector quantity, meaning is has a magnatude and a direction.The just think of the magnatude as how fast the body is going.Technicly I think you are saying the same thing as what Zotoaster is saying. I guess this is what you wanted.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 26th Jun 2007 23:24
I think what you are asking is that the bike always moves in the way that it faces. Realistically, you would calculate the friction between the wheels and the floor, but for a game there's no point in doing this.

Anyway, just like 'direction' is a vector, so it position. In that second equation, I meant you affect the X, Y and Z values seperatelly. Therefore, you could just say:

Position.X = Position.X + (Direction.X * Speed)
Position.Y = Position.Y + (Direction.Y * Speed)
Position.Z = Position.Z + (Direction.Z * Speed)

Hope that helps

Commander in Chief
18
Years of Service
User Offline
Joined: 15th Apr 2006
Location: Carbondale, PA, USA
Posted: 27th Jun 2007 00:22
There is no Direction variable besides MDir and it is a vector and speed is a float. You cannot multiply these together. I tried that exact same equation and it would not run.

---PlasmaArts---
www.plasmaarts.co.nr - www.plasmaarts-games.co.nr
Commander in Chief
18
Years of Service
User Offline
Joined: 15th Apr 2006
Location: Carbondale, PA, USA
Posted: 27th Jun 2007 00:25 Edited at: 27th Jun 2007 00:27
Oh, duh!! I cannot believe I missed that! I forgot the .X and .Y and .Z at first time I tried that and therefore it was a vector!

Thank you!

Also, how do I change the rate it accelerates? Currently it just bolts off. It needs to gradually speed up. Is there a way to set the top speed? It just immediately hits top speed (which is very, very slow).

---PlasmaArts---
www.plasmaarts.co.nr - www.plasmaarts-games.co.nr
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Jun 2007 01:20
If you read the tut

You can either lower the engine force, or increase the mass.

Commander in Chief
18
Years of Service
User Offline
Joined: 15th Apr 2006
Location: Carbondale, PA, USA
Posted: 27th Jun 2007 01:58
Neither of those work,

I need it to slowly accelerate (like a bike) but the top speed should be quite fast.

---PlasmaArts---
www.plasmaarts.co.nr - www.plasmaarts-games.co.nr
Existence
17
Years of Service
User Offline
Joined: 20th May 2007
Location:
Posted: 27th Jun 2007 10:45
I'm gussing that you need to take your magnatude(speed) and have it start from rest(0) and increase it by some number like 0.5 as long as the button that makes it move is pressed.

Look at this thread for it kind of answers your previous question

http://forum.thegamecreators.com/?m=forum_view&t=101199&b=6

If you keep scrolling down you will see code by Green7. He makes a very good example.

Hope this helps

Login to post a reply

Server time is: 2024-09-27 01:14:11
Your offset time is: 2024-09-27 01:14:11