|
Making a "Hitbox"
#134337
06/06/07 20:01
06/06/07 20:01
|
Joined: May 2006
Posts: 69 Canada
Leaf
OP
Junior Member
|
OP
Junior Member
Joined: May 2006
Posts: 69
Canada
|
The idea is common, but no tutorial on how to make a 2d or 3d Hitbox. Example: http://www.spoonix.org/downloads/hitbox.jpgWhat I am looking for is: { (If 0x,0y of player camera is looking at self <= Number of quants //distance away that the bounding box will show up so you wont see it if your 0x,0y crosses over it half way accross the level//) Show bounding box } So basicly, how do I write that so when I look over at a desk from 100 quants away the boundingbox/"hitbox" will apear when my aimer is over it. Thanks, Leaf
Last edited by Leaf; 06/06/07 20:02.
|
|
|
Re: Making a "Hitbox"
[Re: Scorpion]
#134341
06/07/07 20:57
06/07/07 20:57
|
Joined: May 2006
Posts: 69 Canada
Leaf
OP
Junior Member
|
OP
Junior Member
Joined: May 2006
Posts: 69
Canada
|
Quote:
i don't have the time for a code, but try this: use a easy particle with the beam flag, the direction you give with the effect-instruction the partilce must ahve a lifespan of 1.... youy haveto make a while, that emmit every frame 12 effects, which go from one of the 8-points to another one
I under stand what you mean, but I dont know hwo to write the IF statment so when im looking at it and im within so many quants it will show up ![](/ubbthreads/images/graemlins/tongue.gif)
|
|
|
Re: Making a "Hitbox"
[Re: Leaf]
#134342
06/07/07 22:26
06/07/07 22:26
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
Code:
... if(my.clipped != on && vec_dist(my.x,camera.x) <= many_quants) { draw_bounding_box(); //your draw function } ...
|
|
|
Re: Making a "Hitbox"
[Re: Leaf]
#134344
06/08/07 05:05
06/08/07 05:05
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Wow, I didn't know about the clipped flag, and it's exactly what I was looking for! Thanks XArthor!
xXxGuitar511 - Programmer
|
|
|
Re: Making a "Hitbox"
[Re: xXxGuitar511]
#134345
06/08/07 05:51
06/08/07 05:51
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
@Leaf: Well you wanted some help with the IF statement, so I wrote it ![](/ubbthreads/images/graemlins/wink.gif) Basicly it checks if the my entity was clipped in the last frame, which means that it is potentially invisible (if clipped = on), so I check if clipped is off or not on (!= on). Then I check if the distance of the my entity to the camera is below or equal a certain value. Just enter a value for "many_quants" @xXxGuitar: No problem mate ![](/ubbthreads/images/graemlins/wink.gif) EDIT: An quick example Code:
action my_bounding_box_char { wait(1); c_updatehull(my,my.frame); wait(2); while(me) { if(my.clipped != on && vec_dist(my.x,camera.x <= 500) { beep; } wait(1); } }
That code should bring some noise into your level (due to the "beep;")
Last edited by Xarthor; 06/08/07 05:56.
|
|
|
Re: Making a "Hitbox"
[Re: Xarthor]
#134346
06/08/07 07:18
06/08/07 07:18
|
Joined: May 2006
Posts: 69 Canada
Leaf
OP
Junior Member
|
OP
Junior Member
Joined: May 2006
Posts: 69
Canada
|
Quote:
@Leaf: Well you wanted some help with the IF statement, so I wrote it ![](/ubbthreads/images/graemlins/wink.gif) Basicly it checks if the my entity was clipped in the last frame, which means that it is potentially invisible (if clipped = on), so I check if clipped is off or not on (!= on). Then I check if the distance of the my entity to the camera is below or equal a certain value. Just enter a value for "many_quants"
@xXxGuitar: No problem mate ![](/ubbthreads/images/graemlins/wink.gif)
EDIT: An quick example Code:
action my_bounding_box_char { wait(1); c_updatehull(my,my.frame); wait(2); while(me) { if(my.clipped != on && vec_dist(my.x,camera.x <= 500) { beep; } wait(1); } }
That code should bring some noise into your level (due to the "beep;")
Thanks man I got it figured Needed to move some brackets around and shorten the action name. Got "action not found" error because the name was too long Also, added a wait to the action so it doesn't beep out of control and lag to hell. Heres what ive changed it too.
Perfect script man I can now use it to make triggers to open doors easier Well here it is working script for it:
ACTION bounding_box { my.shadow = on; my.gravity = 1; my.entity_type = 2; my.enable_scan = on; wait(1); my.enable_impact = on; my.polygon= on; c_updatehull(my,my.frame); wait(2); while(1) { if(my.clipped != on && vec_dist(my.x,camera.x) <= 500) { wait(100); beep; } wait(1); } }
Your if statement was: if(my.clipped != on && vec_dist(my.x,camera.x <= 500)
Mine changed to work: if(my.clipped != on && vec_dist(my.x,camera.x) <= 500)
Just a mixup of brackets ![](/ubbthreads/images/graemlins/laugh.gif)
Last edited by Leaf; 06/08/07 07:20.
|
|
|
|