Followers 0

Updating velocity to move towards a vector

1 post in this topic

I want to make smoke particles move towards a certain 3D point.

D3DXVECTOR3 startPosition;
D3DXVECTOR3 endPosition;
D3DXVECTOR3 m_velocity;

The particles should start at startPosition and move towards endPosition

I'm updating the velocity for each particle every frame by doing something like:

position += m_velocity * timeElapsed;

How do I set  m_velocity  to make the particles move towards endPosition ?

0

Share on other sites

I'm not directx expert, but something like this:

D3DXVECTOR3 direction = endPosition - startPosition;
D3DXVec3Normalize(direction);
m_velocity = direction * speed;  

Where speed is a scalar value (A float or double) that represents how fast you want to move.

1

Create an account

Register a new account