Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
spawning entity at mousepointer #123590
04/13/07 08:15
04/13/07 08:15
Joined: Nov 2006
Posts: 3
S
shandryx Offline OP
Guest
shandryx  Offline OP
Guest
S

Joined: Nov 2006
Posts: 3
Hi there, for our game we need to create several buildings at the mousepointer ala command and conquer. Now the manual for gamestudio doesn't provide enough information on how to do this. Can anyone help my projectgroup with this by providing some code or linking a manual? This is what we have so far

Code:
function buildbuilding
{
var buildingspawnpos[3] = mouse_pos.x, mouse_pos.y, -500;

if(mouse_left == 1)
{
ent_create( "witch.MDL", buildingspawnpos, NULL );
}

}


We also have buttons that can be pressed, so we can detect the mouse pos. We use a panel to spawn these buildings, but so far we can only spawn them if we imput coordinates, other than 'mouse_pos.x and mouse_pos.y'.

Re: spawning entity at mousepointer [Re: shandryx] #123591
04/13/07 08:27
04/13/07 08:27
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline
Member
nipx  Offline
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
use vec_for_screen:

Code:
 

function BuildBuilding()
{
var vecSpawnPos[3];

if(mouse_left)
{
vec_set(vecSpawnPos, vector( mouse_pos.x,mouse_pos.y, camera.z));
vec_for_screen(vecSpawnPos, camera);
ent_create( "witch.MDL", vecSpawnPos, NULL );
}
}


i guess you call this funcion after you clicked on a button, dont you?
so you propably have to you a while loop. :p


nipx



Re: spawning entity at mousepointer [Re: nipx] #123592
04/13/07 10:41
04/13/07 10:41
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Try something like this... I've jused this in test of rpg game with isometric view:)

function moving_mouse //or you can put this to main function in loop
{
while(1)
{
MOUSE_POS.X = POINTER.X; MOUSE_POS.Y = POINTER.Y;
wait(1);
}
}

function gravity
{
vec_set(temp, my.x);
temp.z -= 10000; // trace downwards 500 quants below
trace_mode = IGNORE_ME + IGNORE_PASSABLE + IGNORE_SPRITES + ignore_models + use_box + scan_texture;
result = trace (my.x, temp);
my.z -= result; // put me on the ground
}

function spawn
{
temp.x = MOUSE_POS.x;
temp.y = MOUSE_POS.y;
temp.z = 500; // how far from camera
vec_for_screen(temp,CAMERA);
you = ENT_CREATE("witch>mdl",temp,gravity);
}

ON_MOUSE_LEFT = spawn;


Never say never.
Re: spawning entity at mousepointer [Re: tompo] #123593
04/13/07 10:45
04/13/07 10:45
Joined: Apr 2005
Posts: 3,076
Germany, NRW
rvL_eXile Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
Copy the "ON_MOUSE_LEFT = spawn;" in ure Main Function


Tutorials:
[Blender]Terrain creation ENG/GER
[Blender]Low Poly Tree Modeling
[GIMP]Create a Texture for Terrains
CLICK HERE


Re: spawning entity at mousepointer [Re: rvL_eXile] #123594
04/13/07 11:00
04/13/07 11:00
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Angel... why?
You don't have to copy this to main function.
It could be enywhere like separate line of code, at the bottom of wdl


Never say never.
Re: spawning entity at mousepointer [Re: tompo] #123595
04/13/07 11:03
04/13/07 11:03
Joined: Apr 2005
Posts: 3,076
Germany, NRW
rvL_eXile Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
Sry my Fault


Tutorials:
[Blender]Terrain creation ENG/GER
[Blender]Low Poly Tree Modeling
[GIMP]Create a Texture for Terrains
CLICK HERE


Re: spawning entity at mousepointer [Re: rvL_eXile] #123596
04/13/07 11:06
04/13/07 11:06
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Can You give me a star for this? Joke


Never say never.

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