Gamestudio Links
Zorro Links
Newest Posts
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
Zorro version 3.0 prerelease!
by TipmyPip. 02/24/26 17:09
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (Martin_HH, TipmyPip, AndrewAMD, Grant), 5,825 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Drag entity at run time [Re: harry3174] #173526
12/30/07 19:28
12/30/07 19:28
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Yes, because vec_for_screen convert screen XY position to world XY position,
so there will be no problem in bird view. In front view, worldposition->x
is the screen depth, it's difficult to convert it from screenpos->x or
mouse_pos.x.

You may try to search the forum to find a workaround, or try my solution :

Code:

entity* ent; // selected entity
var speed = 500; // play with 500

function deSelect()
{
if (ent != NULL)
{
ent = NULL;
}
mouse_pointer = 1;
}

function selectMe()
{
if(event_type == event_click)
{
mouse_pointer = 0;
ent = my;

while(ent == my)
{
my.x += mouse_force.y * speed * time_step;
my.y -= mouse_force.x * speed * time_step;
wait(1);
}
}
}

action clickMe
{
c_setminmax(my);
sp = my;
my.INVISIBLE = On;
my.enable_click = on;
my.event = selectMe;

while(my)
{
if (vec_dist(my.x,earth.x)< 50) // play with 50
{
earth.INVISIBLE = On;
my.INVISIBLE = Off;
}
wait(1);
}
}

on_mouse_left = deSelect; // put it outside any functions




Re: Drag entity at run time [Re: vlau] #173527
01/02/08 04:18
01/02/08 04:18
Joined: Oct 2007
Posts: 85
H
harry3174 Offline OP
Junior Member
harry3174  Offline OP
Junior Member
H

Joined: Oct 2007
Posts: 85
Thank you very much and Happy new year.

I want to try your solution sir.
I am very sorry i cant understand.
Can you little explain please ?

Thanks

Re: Drag entity at run time [Re: harry3174] #173528
01/02/08 09:27
01/02/08 09:27
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Which part you don't understand?
- Copy the above code in your wdl
- Setup your camera, camera movement code in function main
- Assign the action "clickMe" to all your entities that you want to move

When run the level, move the mouse pointer over an entity then left
clicking on it, the mouse pointer will be invisible, now you can move
your entity with your mouse (no need to hold down the mouse button).
Click the LMB again when you want to drop the entity.

Re: Drag entity at run time [Re: vlau] #173529
01/02/08 11:25
01/02/08 11:25
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
You may also look at my Visual Level Editor(posted on Acknex Unlimited in demos section). It's open sourced, and it features dragging objects with mouse.

Re: Drag entity at run time [Re: Shadow969] #173530
01/03/08 10:01
01/03/08 10:01
Joined: Oct 2007
Posts: 85
H
harry3174 Offline OP
Junior Member
harry3174  Offline OP
Junior Member
H

Joined: Oct 2007
Posts: 85
Hi,
Thanks for your kind co-opration Sir.

You define entity ent which i convert entity earth because my movable entity is earth.In action clickMe that while loop ,i used it in action sp_entity.
So i change little things and run the script.when i click on earth entity its move up and then dont move.Other thing is
sp entity visible when run script and when i click earth it invisible.I think sp_entity action cant work.
In function main() i change
vec_set(camera.z,vector(0,0,200)); // 2000 = camera z-pos
camera.pan = 90;

should i somewhere wrong ? Here is code :
//
// modelNodePath.wdl
//C-SCRIPT----------------****************************------------------------
// Alternate path finding/following method
// You need A7.04 WED to open the wmp file

var video_mode = 8;
var video_depth = 32;
var x;
var y;
var z;

ENTITY* earth;
ENTITY* sp;
function main()
{
level_load("drag.wmb");
wait(2);
// bird view
vec_set(camera.z,vector(0,0,200)); // 2000 = camera z-pos
camera.pan = 90;
mouse_mode = 2;
mouse_range = 10000;

while(1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
if (key_w){
camera.tilt += 2 * time_step;
}
if (key_s) {
camera.tilt -= 2 * time_step;
}
if (key_a) {
camera.pan += 2 * time_step;
}
if (key_d){
camera.pan -= 2 * time_step;
}
wait(1);
}
}

action sp_entity
{
while (earth==NULL) {wait(1);}
my.INVISIBLE = On;

while(my)
{
if (vec_dist(my.x,earth.x)< 20) // play with 50
{
earth.INVISIBLE = On;
my.INVISIBLE = Off;
}
else
{
earth.x = x;
earth.y = y;
earth.z = z;
}
wait(1);
}
}

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

var speed = 500; // play with 500

function deSelect()
{
if (earth != NULL)
{
earth = NULL;
}
mouse_pointer = 1;
}

function selectMe()
{
if(event_type == event_click)
{
mouse_pointer = 1;
earth = my;

while(earth == my)
{
my.x += mouse_force.y * time_step;
my.y -= mouse_force.x * time_step;
wait(1);
}
}
}

action clickMe
{
c_setminmax(my);
sp = my;
//my.INVISIBLE = On;
my.enable_click = on;
my.event = selectMe;
}

on_mouse_left = deSelect; // put it outside any functions

Re: Drag entity at run time [Re: harry3174] #173531
01/03/08 10:43
01/03/08 10:43
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Hello Harry,

Please upload your level (.wmp and .wdl) and describe what
you exactly to achieve more clearly, then I can help you to
complete your code and send it back to you.

Unless you're familiar with c-script, modify any part of the
code that you don't understand didn't help.

x,y,z are preserved engine variables, better don't use it as
global and local var.



Last edited by vlau; 01/03/08 10:48.
Re: Drag entity at run time [Re: vlau] #173532
01/04/08 04:24
01/04/08 04:24
Joined: Oct 2007
Posts: 85
H
harry3174 Offline OP
Junior Member
harry3174  Offline OP
Junior Member
H

Joined: Oct 2007
Posts: 85
Thank you sir,

I am new to 3dgs and using Lite-C.Just complete lite-C work-shop.Here i attech.

http://files.filefront.com/snapcdrar/;9375932;/fileinfo.html

For now the camera is on top view. The camera is only tilting but i wanted it to pan in all directions.
In function main you use line : camera.tilt = -90;that i want to change as
camera.pan = 90;.When user use arrow key ,camera should pan.

Thanks
Alpa

Re: Drag entity at run time [Re: harry3174] #173533
01/04/08 14:33
01/04/08 14:33
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Here is the new level + wdl : drag_new

Hope that solved all your problem.

Re: Drag entity at run time [Re: vlau] #173534
01/07/08 06:36
01/07/08 06:36
Joined: Oct 2007
Posts: 85
H
harry3174 Offline OP
Junior Member
harry3174  Offline OP
Junior Member
H

Joined: Oct 2007
Posts: 85
Thank you very much for kind co-operation Sir.

Earth entity moves along the walls. It can’t in touch with sp entity.
I am not able to explain properly to you what i want to do. So I attach exe here with which is made in director 3d.

I want to do that with game studio.

In drag_new (which was you sand ) when I use arrow key its rotate properly. This pan effect I want in that level which I send previously.

http://files.filefront.com/24+heartrar/;9393803;/fileinfo.html

Please help me.
Thanks

Re: Drag entity at run time [Re: harry3174] #173535
01/07/08 08:19
01/07/08 08:19
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
The test level works fine here, you've to move your
mouse slowly to drag it close to the sp_entity.

If you need someone to write a program just like
your demo, you may post it on the Job Offer forum.

Good luck!

EDIT
----
Just some hints : c_trace work different than modelsunderray in
Director3D, it return the closest model only.


Last edited by vlau; 01/07/08 08:36.
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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