Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (vicknick, AndrewAMD), 1,292 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Junior Member
crumply  Offline 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:

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] #222879
08/21/08 13:11
08/21/08 13:11
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline
Serious User
pegamode  Offline
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi crumply,

maybe you could use a trace from camera position to the mousepointer.

This is the code I use in my point&click adventure:

pos2.x = mouse_pos.x;
pos2.y = mouse_pos.y;
pos2.z = 10000;
vec_for_screen (pos2, camera);
trace_mode = IGNORE_PASSABLE + IGNORE_PASSENTS + IGNORE_FLAG2;
c_trace (camera.x, pos2, trace_mode);

Now you can use 'target' to place your new entity.

Regards,
Pegamode


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 Offline
Expert
Joozey  Offline
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] #222884
08/21/08 13:43
08/21/08 13:43
Joined: Mar 2008
Posts: 67
crumply Offline OP
Junior Member
crumply  Offline OP
Junior Member

Joined: Mar 2008
Posts: 67
Joozey that's a good point you make about assigning the mouse_cursor. Both you guys helped me get it working and I am so happy right now laugh

here's what I'm working on, a survival sim:



GStudio forum saves the day again! laugh

Re: Using the mouse to create an entity on the level [Re: crumply] #222887
08/21/08 13:52
08/21/08 13:52
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Looks like a fun start grin


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 Offline OP
Junior Member
crumply  Offline OP
Junior Member

Joined: Mar 2008
Posts: 67

Re: Using the mouse to create an entity on the level [Re: crumply] #223025
08/21/08 22:50
08/21/08 22:50
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Oh that's freaky hehe, looks like zombie trees. Definately original ^^ would be great if it somehow animated a little so it really looks like it grows. I'm looking forward to see the rest laugh.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Using the mouse to create an entity on the level [Re: Joozey] #223533
08/25/08 00:01
08/25/08 00:01
Joined: Oct 2007
Posts: 27
P
phmenard Offline
Newbie
phmenard  Offline
Newbie
P

Joined: Oct 2007
Posts: 27
crumpy how did you create the map in the bottom left hand corner ... I've been looking for a working example.


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