Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/06/23 11:29
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
7 registered members (fairtrader, Quad, miwok, Martin_HH, AndrewAMD, alibaba, dpn), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
reverse in front off !! #106642
01/13/07 11:00
01/13/07 11:00
Joined: Dec 2004
Posts: 237
H
Hani Offline OP
Member
Hani  Offline OP
Member
H

Joined: Dec 2004
Posts: 237
hi there,
if i want an entity to be alwas 10 q in front of the player and 6q above ,i 'll use this code

vec_set(temp , vector(10,0,6));
vec_rotate(temp , player.pan);
vec_add(temp , player.x);

now temp hold the cordiantion.

what i want is the reverse of that, meaning , if an entity hit the player someware, i need it to stki there no mater how mush the player rotates ..


i need this to make the arrows that hit my player stik in to him where ever he moves ..

thanks


The deference between madness and geniuses is success
Re: reverse in front off !! [Re: Hani] #106643
01/13/07 14:52
01/13/07 14:52
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
What I would do is:

-enable the arrow's "enable_entity". (you probably already have that, if the arrow's working).
-Then have some skill set to 1 as soon as it hit something.
-save what entity it hit and from then on move around with that entity.

Code:
 

define stuck_ent,skill10;
define pan_angle,skill11;
define direction,skill12;
define distance,skill15;

function arrow_function()
{
if(event_type == event_entity)
{
my.stuck_ent= handle(you);
my.pan_angle= my.pan - you.pan;
vec_diff(my.direction,my.x,you.x);
my.distance = vec_lenght(my.x,you.x);
}
}

action arrow
{
my.enable_entity = on;
my.event= arrow_function;
... your code
while(1)
{
if(my.skill10 != 0)
{
you = ptr_for_handle(my.stuck_ent);
my.pan = you.pan + my.pan_angle;
vec_set(temp,my.direction);
vec_scale(temp,my.distance);
vec_add(temp,player.x);
vec_set(my.x,temp);
}
wait(1);
}
}




I just came up with this... I just hope it helps...and works.

Micha


~"I never let school interfere with my education"~
-Mark Twain
Re: reverse in front off !! [Re: Germanunkol] #106644
01/13/07 16:37
01/13/07 16:37
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
May be simply put your rotate code
inside a loop and set the player.pan
to the arrow.pan, like this example :

Code:

while(1)
{
vec_set(arrow.x, vector(10,0,6));
vec_rotate(arrow.x, player.pan);
vec_add(arrow.x , player.x);
vec_set(arrow.pan, player.pan);
wait(1);
}



Re: reverse in front off !! [Re: vlau] #106645
01/14/07 12:18
01/14/07 12:18
Joined: Dec 2004
Posts: 237
H
Hani Offline OP
Member
Hani  Offline OP
Member
H

Joined: Dec 2004
Posts: 237
thanks all,
but dear Germanunkol what do you mean by

my.distance = vec_lenght(my.x,you.x); ??
cause vec_length taks a vector

thanks


The deference between madness and geniuses is success
Re: reverse in front off !! [Re: Hani] #106646
01/14/07 16:19
01/14/07 16:19
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
my.x and you.x are vectors same thing as saying vec_Lenght(vector(my.x,my.y,my.z),vector(you.x,you.y,you.z));


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: reverse in front off !! [Re: FoxHound] #106647
01/15/07 07:26
01/15/07 07:26
Joined: Dec 2004
Posts: 237
H
Hani Offline OP
Member
Hani  Offline OP
Member
H

Joined: Dec 2004
Posts: 237
thanks,
but there is no vec_Lenght ,
there is vec_length that take only a vector as an input .


The deference between madness and geniuses is success
Re: reverse in front off !! [Re: Hani] #106648
01/15/07 14:10
01/15/07 14:10
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
True, but my.x, as foxhound said, is a vector. it's the same as vector(my.x,my.y,my.z);
for example:
vec_set(temp,my.x);

sets temp.x to my.x
temp.y to my.y
and temp.z to my.z...
c_script does the same with my.pan... if you use it in a simple math problem like
my.pan + = 10;
it just sees it as my.pan. But if you use it in a vector instruction like vec_set or vec_lenght it sees it as a vector, and it's the same as putting in my.x, my.y and my.z...
also, c_script isn't case sensitive (thank God!), so writing vec_Length and vec_length is the same...:)

Hope that made it understandable... if not, read through the page that the manual has on "vectors"...
Micha


~"I never let school interfere with my education"~
-Mark Twain
Re: reverse in front off !! [Re: Germanunkol] #106649
01/15/07 14:59
01/15/07 14:59
Joined: Dec 2004
Posts: 237
H
Hani Offline OP
Member
Hani  Offline OP
Member
H

Joined: Dec 2004
Posts: 237
dear Germanunkol ,
i didn't understand me, i know that my.x == to vector(my.x,my.y.my.z);

but in your code

Quote:

my.distance = vec_lenght(my.x,you.x);




the vec_length() function takes only one vector, and your supllying 2, so
do you mean vec_sub(temp , my.x , you.x) and then get the length ?


The deference between madness and geniuses is success
Re: reverse in front off !! [Re: Hani] #106650
01/15/07 17:00
01/15/07 17:00
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
uh, right! I'm sorry... that's embarrassing. Try vec_dist instead, it should hopefully work. I know what you mean now... vec_lenght is not the distance between the two vectors. I meant vec_dist. That should return the distance between the two vectors.

@ vlau, I was thinking of doing it your way as well. The problem with that is that is that each arrow is, relative to the player's pan and position, always at the same spot. So what I try to do is save: a) the difference in angles, b) the direction from the player.x to the arrow, c) the distance between the two. then, each frame after that, these are rotated by the player's pan and added to his x. That way, if the player was hit in the chest it should stay there, and if he was hit in the stomach it should stick there for ever... I don't know if it works, but that's what I'm aming for....

@ Hani: I'm sorry, I just noticed something was wrong with my code:

instead of:
you = ptr_for_handle(my.stuck_ent);
my.pan = you.pan + my.pan_angle;
vec_set(temp,my.direction);
vec_scale(temp,my.distance);
vec_add(temp,player.x);
vec_set(my.x,temp);

try
you = ptr_for_handle(my.stuck_ent);
my.pan = you.pan + my.pan_angle;
vec_set(temp,my.direction);
vec_rotate(temp,player.pan);
vec_scale(temp,my.distance);
vec_add(temp,player.x);
vec_set(my.x,temp);


And also change vec_lenght to vec_dist, as mentioned before.
Hope it works!!

Micha


~"I never let school interfere with my education"~
-Mark Twain
Re: reverse in front off !! [Re: Germanunkol] #106651
01/17/07 09:19
01/17/07 09:19
Joined: Dec 2004
Posts: 237
H
Hani Offline OP
Member
Hani  Offline OP
Member
H

Joined: Dec 2004
Posts: 237
dear Germanunkol,
thanks for your help, i've tested your code theres 2 things need update.
1- the my.distance = vec_dist(my.x,you.x) is not necessary, cause the vec_diff
retun the exact distance.
2- we must rotate the destance vector by you -pan , -tilt , - roll , in the arrow event:
vec_rotate(my.direction ,vector(- you.pan , -you.tilt , -you.roll));
cause if the hited entity pan == 0 and the arrow hit it from the left, the code work fine, but if the hited entity pan was 90, this mean the arrow must hitme from the back, if we didn't add the rotation line the arrow will apear in front of the entity..

thanks a lot for your help


The deference between madness and geniuses is success
Page 1 of 2 1 2

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