Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Ayumi, ozgur), 678 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
get the velocity of c_move #177732
01/13/08 12:41
01/13/08 12:41
Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30"E
Frederick_Lim Offline OP
User
Frederick_Lim  Offline OP
User

Joined: Oct 2003
Posts: 827
22�21'24"N 114�07'30"E
I want to attach a particle tail to the entity, how to calculate the velocity of entity movement?

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
I
Impaler Offline
Member
Impaler  Offline
Member
I

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] #177734
01/14/08 04:24
01/14/08 04:24
Joined: Jul 2005
Posts: 34
Hong Kong
U
ultranet Offline
Newbie
ultranet  Offline
Newbie
U

Joined: Jul 2005
Posts: 34
Hong Kong
Yes, the velocity vector is specified by the user.

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 Offline OP
User
Frederick_Lim  Offline 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 Offline
User
Trooper119  Offline
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 Offline OP
User
Frederick_Lim  Offline 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.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1