|
1 registered members (1 invisible),
3,952
guests, and 0
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Using the mouse to create an entity on the level
#222877
08/21/08 12:59
08/21/08 12:59
|
Joined: Mar 2008
Posts: 67
crumply
OP
Junior Member
|
OP
Junior Member
Joined: Mar 2008
Posts: 67
|
I'm trying to make my script create an entity by tracing a ray from the mouse down to the first collidable object in the level. From what I understand from vector maths, I trace from the camera position to (mouse_dir3d*distance + camera position). I've tried for about 2 hours now and I still can't get it to work and I've also tried searching the forums and it always gives me the same list of topics that are completely irrelevant! I am fuming! Please someone put me out of my misery and tell me how it's done. Here's my code: if(mouse_left == 1) // left Mousebutton pressed?
{
mousetracertemp.x = vector(0,0,0);
vec_add(mousetracertemp,mouse_dir3d);
vec_scale(mousetracertemp,1000);
vec_add(mousetracertemp,vector(camera.x,camera.y,camera.z));
printv("yep",c_trace(camera, mousetracertemp, USE_POLYGON | IGNORE_ME));
ent_create("mcube.mdl",mousetracertemp,NULL);
printv("x",mousetracertemp.x);
printv("y",mousetracertemp.y);
printv("z",mousetracertemp.z);
while(mouse_left==1) wait(1);
}
|
|
|
Re: Using the mouse to create an entity on the level
[Re: crumply]
#222880
08/21/08 13:14
08/21/08 13:14
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Using the mouse to create an entity on the level
[Re: Joozey]
#222952
08/21/08 18:10
08/21/08 18:10
|
Joined: Mar 2008
Posts: 67
crumply
OP
Junior Member
|
OP
Junior Member
Joined: Mar 2008
Posts: 67
|
|
|
|
|