Skip to main content
Added ElapsedTime to the position calculation
Source Link

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

Force = Direction * Power
Acceleration = Force / Mass
Velocity += Acceleration * ElapsedTime
Position += Velocity * ElapsedTime

Direction being a unit length vector giving the heading of your ship. Power being the amount of thrust you want to add (Zero when no acceleration is needed) ElapsedTime is the time between your game Update calls to keep movement smooth even when your framerate is changing

If you want to know more about it you can look up Euler Integration

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

Force = Direction * Power
Acceleration = Force / Mass
Velocity += Acceleration * ElapsedTime
Position += Velocity

Direction being a unit length vector giving the heading of your ship. Power being the amount of thrust you want to add (Zero when no acceleration is needed) ElapsedTime is the time between your game Update calls to keep movement smooth even when your framerate is changing

If you want to know more about it you can look up Euler Integration

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

Force = Direction * Power
Acceleration = Force / Mass
Velocity += Acceleration * ElapsedTime
Position += Velocity * ElapsedTime

Direction being a unit length vector giving the heading of your ship. Power being the amount of thrust you want to add (Zero when no acceleration is needed) ElapsedTime is the time between your game Update calls to keep movement smooth even when your framerate is changing

If you want to know more about it you can look up Euler Integration

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

Force = Direction * Power
Acceleration = Force / Mass * ElapsedTime
Velocity += Acceleration * ElapsedTime
Position += Velocity

Direction being a unit length vector giving the heading of your ship. Power being the amount of thrust you want to add (Zero when no acceleration is needed) ElapsedTime is the time between your game Update calls to keep movement smooth even when your framerate is changing

If you want to know more about it you can look up Euler Integration

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

Force = Direction * Power
Acceleration = Force / Mass * ElapsedTime
Velocity += Acceleration * ElapsedTime
Position += Velocity

Direction being a unit length vector giving the heading of your ship. Power being the amount of thrust you want to add (Zero when no acceleration is needed) ElapsedTime is the time between your game Update calls to keep movement smooth even when your framerate is changing

If you want to know more about it you can look up Euler Integration

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

Force = Direction * Power
Acceleration = Force / Mass
Velocity += Acceleration * ElapsedTime
Position += Velocity

Direction being a unit length vector giving the heading of your ship. Power being the amount of thrust you want to add (Zero when no acceleration is needed) ElapsedTime is the time between your game Update calls to keep movement smooth even when your framerate is changing

If you want to know more about it you can look up Euler Integration

Expanded on my original answer
Source Link
Mr Bell
  • 405
  • 2
  • 12

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

AccelerationForce = Direction * Power //where power is the
Acceleration amount= ofForce thrust/ youMass are* addingElapsedTime
Velocity += Acceleration * ElapsedTime
Position += Velocity

This isDirection being a simple way to get what you are afterunit length vector giving the heading of your ship. However, for it to work right, Power being the amount of thrust you needwant to have a constantadd (Zero when no acceleration is needed) ElapsedTime is the time between updates, which you probably won't have once your game gets in full swing. To correct for it you needUpdate calls to take into account the elapsedTime between updates like so:keep movement smooth even when your framerate is changing

Acceleration = Direction * Power * ElapsedTime
Velocity += Acceleration * ElapsedTime
Position += Velocity

If you want to know more about it you can look up Euler Integration

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

Acceleration = Direction * Power //where power is the amount of thrust you are adding
Velocity += Acceleration
Position += Velocity

This is a simple way to get what you are after. However, for it to work right, you need to have a constant time between updates, which you probably won't have once your game gets in full swing. To correct for it you need to take into account the elapsedTime between updates like so:

Acceleration = Direction * Power * ElapsedTime
Velocity += Acceleration * ElapsedTime
Position += Velocity

If you want to know more about it you can look up Euler Integration

It looks like you have Position and Direction as vectors and Velocity as a scalar?

If so just change Velocity into a vector as well and then do something like this:

Force = Direction * Power
Acceleration = Force / Mass * ElapsedTime
Velocity += Acceleration * ElapsedTime
Position += Velocity

Direction being a unit length vector giving the heading of your ship. Power being the amount of thrust you want to add (Zero when no acceleration is needed) ElapsedTime is the time between your game Update calls to keep movement smooth even when your framerate is changing

If you want to know more about it you can look up Euler Integration

Expanded on my original answer
Source Link
Mr Bell
  • 405
  • 2
  • 12
Loading
Source Link
Mr Bell
  • 405
  • 2
  • 12
Loading