Sign in to follow this  

Distance over Time

This topic is 1963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am currently trying to model a projectile in Physx. I would like a force to be applied to this projectile every ten seconds. I have never used time functions before. I currently have access to time using
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&previousTime);

and with this i get the elapsed time. but i am not sure how to create a ten second counter. something that will just return tru when the elapsed time reaches ten seconds.

I know this is simple but for some reason my mind is stumped. i just need some one to potentially explain how this works.

thanks [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] Edited by greenzone

Share this post


Link to post
Share on other sites
[code]
// simplified pseudocode
class Timer
{
public:
Timer(int duration)
{
this.duration = duration;
this.start = GetCurrentTime(); // replace GetCurrentTime() with whatever the right function is for your target API
}

void restart()
{
this.start = GetCurrentTime();
}

bool finished()
{
return GetCurrentTime() >= this.start + this.duration;
}

private:
int start, duration;
};
[/code]

Of course, you're free to ask questions, but I tried to make it uber simple and hopefully self explanatory.

Share this post


Link to post
Share on other sites
[quote name='greenzone' timestamp='1343956926' post='4965702']
i am currently trying to model a projectile in Physx. I would like a force to be applied to this projectile every ten seconds. I have never used time functions before. I currently have access to time using
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&previousTime);

and with this i get the elapsed time. but i am not sure how to create a ten second counter. something that will just return tru when the elapsed time reaches ten seconds.

I know this is simple but for some reason my mind is stumped. i just need some one to potentially explain how this works.

thanks [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img]
[/quote]

If you are trying to model a projectile, why are you applying a force every 10 seconds? By the definition of a projectile, the only force acting on the projectile should be gravity. but gravity is a constant force... it is not applied every 10 seconds. If a force is being applied to the body other than gravity, than it is not a projectile and you are trying to model something different (imo).

Even if I assume you mean some sort of thrust (not a projectile) that is being applied to the "projectile", what sorts of thrust would occur every 10 seconds?

I imagine that it is possible that you want some sort of "homing" projectile which must constantly correct its angle to locate the target. In that context perhaps a 10 second interval for course correction would make sense. If that is the case then this link: [url="http://answers.unity3d.com/questions/48836/determining-the-torque-needed-to-rotate-an-object.html"]http://answers.unity3d.com/questions/48836/determining-the-torque-needed-to-rotate-an-object.html[/url] may help

I only bring this up because from the statement of your problem it is possible that you may need to reconsider the approach.

Look at the PhysX documentation and look to see if you can find something about applying forces and impulses. I think this may help you.

Share this post


Link to post
Share on other sites
shadowisadog, your right i am setting up a homing missile and i need to correct the tangent velocity angle for the uniform circular motion to work correctly. I only wrote every seconds because i didn't have a precise time in my head lol. realistically it would be tenth or hundredth of a second depending on how fast the missile is moving. thanks for the link as well.

Share this post


Link to post
Share on other sites

This topic is 1963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this