Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,400 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_trace and direction #425328
07/02/13 22:22
07/02/13 22:22
Joined: Apr 2012
Posts: 106
G
GaniX Offline OP
Member
GaniX  Offline OP
Member
G

Joined: Apr 2012
Posts: 106
i everyone, i have the following question :
i have the enemy, and the enemy scan area use c_scan , if the enemy detect another enemy or the player it uses the c_trace instruction to check if it can shoot and hit the enemy or player.But if it(enemy) is turned left or right, or look up or down the ray of c_trace is not turn like the enemy. how can i do to turn the ray of c_trace.
and another problem is this: supouse the ray of c_trace is hit a window or something else. how can i get the angle of the hit.i need this angle to make the ray of c_trace continue in the right direction.how can i do this?

i study some codes like multitrace but i think i need more practice because i dont understand so much...:(
if anybody can help me i will be gratefull

Re: c_trace and direction [Re: GaniX] #425329
07/02/13 22:37
07/02/13 22:37
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Trace to your point of interest (player or other enemy), if !trace_hit, calculate the angle from the direction of your entity to that object, for instance as follows:

c_trace(my.x,object.x,...);
if(!trace_hit)
{
vec_diff(temp,object.x,my.x);
vec_to_angle(temp2,temp);
// now compare the ANGLE temp2 to the my-orientation to check if the object is in the field of view of the my entity
if(abs(ang(my.pan-temp2.x)) < 90 && abs(ang(my.tilt-temp2.y)) < 50)
{
object is visible in front of my-entity
}
}

I hope this is what you wanted to do. Alternatively you can adapt the scan cone of the c_scan instruction (i.e. not use a full-sphere scan) and combine it with c_trace, then you should not have to compare any angles at all.

Regarding your second question, did you mean "mirror" instead of "window"? If it's only a window you want to ignore you could use the c_ignore feature.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: c_trace and direction [Re: Superku] #425330
07/02/13 23:08
07/02/13 23:08
Joined: Apr 2012
Posts: 106
G
GaniX Offline OP
Member
GaniX  Offline OP
Member
G

Joined: Apr 2012
Posts: 106
ok i will study this idea you say, but are you sure the ray in the c_trace will turn wiht this?, is say turn when the enmy turn o turn when the player look down or up or else ...
because i use the trace isntruction to make the shoot



and for the 2 problem i say : if the ray hit an glass, window, door , or else, how can i get the angle of this hit to continue the ray . supouse the ray hit a window in 45ยบ How can i get the angle to continue the ray ?, How continue the ray?

Last edited by GaniX; 07/02/13 23:22.
Re: c_trace and direction [Re: GaniX] #425331
07/02/13 23:19
07/02/13 23:19
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The my-entity's orientation or any other orientation is irrelevant to c_trace, only the first two parameters of c_traces determine the trace direction.

Check the manual for "bounce".


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: c_trace and direction [Re: Superku] #425332
07/02/13 23:25
07/02/13 23:25
Joined: Apr 2012
Posts: 106
G
GaniX Offline OP
Member
GaniX  Offline OP
Member
G

Joined: Apr 2012
Posts: 106
ok i will do and thanks , if i have a problem i will tell you


Gamestudio download | 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