3 registered members (AndrewAMD, Ayumi, ozgur),
678
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: get the velocity of c_move
[Re: Frederick_Lim]
#177733
01/14/08 03:28
01/14/08 03:28
|
Joined: Aug 2006
Posts: 128 Papua New Guinea
Impaler
Member
|
Member
Joined: Aug 2006
Posts: 128
Papua New Guinea
|
according to the manual, the syntax for c_move is: Quote:
c_move(ENTITY* entity,VECTOR* reldist,VECTOR* absdist,var mode)
and since you have to specify the amount of distance it moves over, it should be easy to find the velocity, it's already in the reldist or absdist part of the above code.
Murphey's Law: << if anything can go wrong, it will >> (Murphey was an optimist).
|
|
|
Re: get the velocity of c_move
[Re: Impaler]
#177735
01/17/08 11:09
01/17/08 11:09
|
Joined: Oct 2003
Posts: 827 22�21'24"N 114�07'30"E
Frederick_Lim
OP
User
|
OP
User
Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30"E
|
I am trying to use this code to get the velocity, the velocity is use by effect() function. I get the velocity by calculate the position before and after c_move(): Code:
bullet_speed.x = 80 * time_step; // adjust the speed of the bullet here
vec_set(pos1.x, my.x); c_move(me, bullet_speed, nullvector, IGNORE_YOU|IGNORE_PASSABLE|IGNORE_FLAG2|ACTIVATE_SHOOT); vec_set(pos2.x, my.x); vec_sub(pos2.x, pos1.x); vec_inverse(pos2); effect(tail,1,my.x,pos2);
I enable beam for the effect(), but the result is very strange, is there anyone can help?
|
|
|
Re: get the velocity of c_move
[Re: Frederick_Lim]
#177736
01/17/08 21:15
01/17/08 21:15
|
Joined: Apr 2004
Posts: 516 USA
Trooper119
User
|
User
Joined: Apr 2004
Posts: 516
USA
|
Frederick, you should know by now that you should post your problem in one place, and document it to the fullest there. If possible give pictures (or if you really good a link to a short video). What people have been saying earlier is true, your value bullet_speed.x is your speed. c_move only moves as far as you let it, or until it runs into something that you deem not passable, but the fact remain that unless it hasn't moved that distance, bullet_speed.x is always the speed given. So unless your result looks strange once you hit an object, your code is rudunant, and you can pass bullet_speed.x if you'd like.
What it looks like your doing now is getting the real distance between the first and second point (before and after c_move) but I believe vec_inverse just gives the opposite of what you give it (+ to -, vise versa). I would suggest trying abs(value); to get the distance (absolute values turn everything to its + value), otherwise you may come up with negative distances, I'm guessing either this, or time_step is your problem, but I can't be 100% certain without pics.
I personally have unresolved issues with time_step, so I'm not a perfect person to ask, but as a few last ditch efforts I would suggest trying to pass just bullet_speed.x into your function and see what happens as a result. Also, you could try passing the event function before the c_move, I doubt it will do anything significant but you never know. Hope one of these solutions work, post back if you have any more problems, and if you find out time_step is giving you issues, please PM me or post back here, I would be interested in your findings.
A clever person solves a problem. A wise person avoids it. --Einstein
Currently Codeing: Free Lite-C
|
|
|
Re: get the velocity of c_move
[Re: Trooper119]
#177737
01/18/08 13:52
01/18/08 13:52
|
Joined: Oct 2003
Posts: 827 22�21'24"N 114�07'30"E
Frederick_Lim
OP
User
|
OP
User
Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30"E
|
Many thanks for reply. I mess up the particle's velocity and c_move function. There are relative and absolute movement vector in c_move, in my code I pass the relative vector in c_move, but is that the velocity vector for particle?
Most particle tutorials are using pre-calculate velocity, however I cannot figure out how to attach particle to moving entity.
Edit: I solved my problem. I just need to divide the length of vector pos2.x, pos2.y, pos2.z by time_step, that's the velocity of c_move relative movement.
Last edited by Frederick_Lim; 01/18/08 18:04.
|
|
|
|