Topic: Get the real-time position of a projectile?
If the player shoots a gun, how would I get the real time position of the bullet and do something with it? Is there a variable for that?
deny_post($poster);
You are not logged in. Please login or register.
Teeworlds Forum → Fan Art and Other → Get the real-time position of a projectile?
If the player shoots a gun, how would I get the real time position of the bullet and do something with it? Is there a variable for that?
WTH...?
The "real time position"?
explain, what do you mean?^^
Like, the player fires a projectile, and I set a var ("shot_time") to when the projectile is fired. Then, if a certain amount of time (one second) passes after shot_time I perform an action, but I need to do it where the projectile is after one second.
you can find it in function tick of class projectile in file src/game/server/gs_server.cpp. you don't need this shot_time. it's saved in objects of projectile in var start_tick. then you can use server_tick() to get the current tick and so on.
Ok, so projectile::tick will yield the real time pos? Thanks. Shot_time is actually modified after the projectile fires, so I will use it.
No, that doesn't work because tick() returns nothing. <.<
Do you want to get position in server or client?
What do you mean by that? What's the difference?
look at the code of this function. It is self-explanatory. You only have to modify projectile::tick():
float pt = (server_tick()-start_tick-1)/(float)server_tickspeed();
float ct = (server_tick()-start_tick)/(float)server_tickspeed();
vec2 prevpos = get_pos(pt);
vec2 curpos = get_pos(ct);
No, that doesn't work because tick() returns nothing. <.<
Uh.. what are you trying to do? You should put your code into this method, not somewhere else.
/edit: ok, scous answered while I was reading some other posts... X-P
Thanks, scousu. I'll check it out later.
Teeworlds Forum → Fan Art and Other → Get the real-time position of a projectile?
Powered by PunBB, supported by Informer Technologies, Inc.
Currently installed 3 official extensions. Copyright © 2003–2009 PunBB.