1 registered members (AbrahamR),
717
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
sprite collision and c_trace
#330520
06/28/10 02:38
06/28/10 02:38
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
Hello
Intro: - I'm using a sprite on the level - I'm using the c_trace from camera to hit the sprite
objective: c_trace the sprite with the mouse, and activate its sonar (sprite) event.
problems: ->the collision is not accurate, in the right side of the sprite or .. the bottom side (ir reacts when mouse is over a little bit from the edge)
-> on the left and upper side it works fine.. -> Does sprites must be power 2? (it would explain the extra hit area, since dX would add a canvas to fit the power of 2 square
Could it be my c_trace method that its not point correctly (though it works on the left and upper side)
Chech my c_trace method:
function m_trace(){ VECTOR to; vec_set(to,mouse_dir3d); vec_scale(to,2000); // set a range vec_add(to,mouse_pos3d); c_trace(mouse_pos3d,to,ACTIVATE_SHOOT | USE_POLYGON |SCAN_TEXTURE); }
AS you can see i set use_polygon to check the sprite but i dont even know if its beeing used...
Solutions anyone?
|
|
|
Re: sprite collision and c_trace
[Re: Rei_Ayanami]
#330568
06/28/10 13:48
06/28/10 13:48
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
MMike, I believe it to be the power-of-two strikes again. But nothing but my own testing, and educated guessing to back me up. If you are using the draw_line3d process to 'visualise' the detected edges of the sprites collision box, try rotating or tilting the sprite by 45 degrees or more... Could this be called a bug?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: sprite collision and c_trace
[Re: EvilSOB]
#330661
06/28/10 23:36
06/28/10 23:36
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
well nice to see your input on this..
but, well using that d3d thing to the vector to point of the trace.. i see it is right on the mouse pos..
but the sprite detects the c_trace on wrong areas..
Evilsob, how do you mean the detect edges with the 3d3 line? show me a sample
Last edited by MMike; 06/28/10 23:44.
|
|
|
Re: sprite collision and c_trace
[Re: MMike]
#330664
06/29/10 00:05
06/29/10 00:05
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
Please anyone can test this sample file, (packed in a rar, its just the button and the script..) and verify what im telling... Download here [4.39Kb] there must always be a problem with the collision stuff.. i mean this subject stinks, and its not the first time it holds my projects... I see i will have to use another panel to overlay the view and .. be a dummy... crap
Last edited by MMike; 06/29/10 00:08.
|
|
|
Re: sprite collision and c_trace
[Re: MMike]
#330692
06/29/10 10:26
06/29/10 10:26
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I havent looked at your upload yet MMike, but this is the detecting with draw_line3d I was talking about. Its not special at all, it just makes it easier to "see".
#include <litec.h>
#include <default.c>
#define PRAGMA_PATH "@Bits"
function main()
{
video_switch(6,0,0); wait(5); level_load(NULL); wait(5);
vec_set(camera.x, vector(-750,250,0));
//
VECTOR from, to;
ENTITY* sprite = ent_create("White_130x130x24.bmp", NULL, NULL);
//
while(1)
{
sprite.y -= key_cur - key_cul;
sprite.z += key_cuu - key_cud;
sprite.pan -= key_del - key_pgdn;
sprite.tilt += key_home - key_end;
if(key_bksp) sprite.y = sprite.z = sprite.pan = sprite.tilt = 0;
//calculate (line-drawable) start and end
vec_set(from, vector(camera.x+10,camera.y,camera.z));
vec_set(to, vector(mouse_cursor.x,mouse_cursor.y,1000)); vec_for_screen(to, camera);
//
if(c_trace(camera.x, to, SCAN_TEXTURE))
{ //Draw RED line to Successful Target
draw_line3d(from, NULL, 100); draw_line3d(target.x, vector(0,0,255), 100);
}
else
{ //Draw WHITE line to mouse
draw_line3d(from, NULL, 100); draw_line3d(to, vector(255,255,255), 100);
}
//
wait(1);
}
}
Imm looking at your code now... [EDIT] Yeah, same thing for me too..
Last edited by EvilSOB; 06/29/10 10:31.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: sprite collision and c_trace
[Re: EvilSOB]
#330751
06/29/10 15:24
06/29/10 15:24
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
well your code above is incomplete,there is not closing brackets.. , but i just fixed it.
Also it gives me an error "White_130x130x24.bmp" saying it does not exist. so i just replaced it with a file of myown.
After that, and testing .. it does the same as mine. There is something weird with the collision.. it does not even work always in the same away, if i move the sprite for another place, the collision is different.
well i have no idea what is this behaviour, and how to fix, (if there is a fix). PS: I would like to hear an expert talking why this happens and how to correct.. PLease can you call JCL on the phone AHHAAh
Last edited by MMike; 06/29/10 15:44.
|
|
|
Re: sprite collision and c_trace
[Re: MMike]
#330766
06/29/10 16:18
06/29/10 16:18
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
hehehe.
I suggest putting it into the bugs forum.
I cant myself, Ive already got three active ones ATM...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|