Jump to content

  • Log In with Google      Sign In   
  • Create Account

Updating velocity to move towards a vector


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 18 January 2013 - 03:14 AM

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 ?



Sponsor:

#2 Milcho   Crossbones+   -  Reputation: 1177

Like
1Likes
Like

Posted 18 January 2013 - 03:35 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS