Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,253 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Move Entity with mouse #137347
06/20/07 20:58
06/20/07 20:58
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
D
Disaster Offline OP
Member
Disaster  Offline OP
Member
D

Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
Hi
I have a maybe very simple problem but i have no idea how to solve it. i just want to move an entity with the mouse over the screen (only in x and y direction).
Could someone please help me?
I have looked in the manual but there is only explained how to rotate an entity with the mouse and here in the forum i couldn't find a post with my problem...


mfg Disaster
Re: Move Entity with mouse [Re: Disaster] #137348
06/21/07 09:33
06/21/07 09: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 a sample code to achieve this, not perfect
but should get you started.

Code:

var speed = 2; // play with 2

action myEntity
{
while(my)
{
my.x += sign(screen_size.y/2 - mouse_cursor.y) * speed * time_step;
my.y += sign(screen_size.x/2 - mouse_cursor.x) * speed * time_step;
wait(1);
}
}

function main()
{
....
....
mouse_mode = 1;
}



Re: Move Entity with mouse [Re: vlau] #137349
06/21/07 19:36
06/21/07 19:36
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
D
Disaster Offline OP
Member
Disaster  Offline OP
Member
D

Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
hi
I've tested your code but there the entity automaticly moves in one direction (to the upper right side of the level in the top-perspective) and you cannot influence the movement with the mouse...


mfg Disaster
Re: Move Entity with mouse [Re: Disaster] #137350
06/22/07 08:36
06/22/07 08:36
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 above code split the screen into 4 quarters, your entity will
move to left or right depends on your mouse pointer located on the
left side or right side of the screen. Also, the entity will move
forward/backward depends on your mouse pointer is on the upper or
lower part of the screen.

As I said it's not a perfect code, you have to modify it to get what you
need, or you have to be more specific about what you want to achieve.

Re: Move Entity with mouse [Re: vlau] #137351
06/22/07 12:24
06/22/07 12:24
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
D
Disaster Offline OP
Member
Disaster  Offline OP
Member
D

Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
I simply want to move my player entity with the mouse and not with the keyboard. maybe i can explain it in such a way that the player entity should be my mouse cursor


mfg Disaster
Re: Move Entity with mouse [Re: Disaster] #137352
06/22/07 13:25
06/22/07 13:25
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
while(1)
{
MOUSE_POS.X = POINTER.X; MOUSE_POS.Y = POINTER.Y;
temp.x = MOUSE_POS.x;
temp.y = MOUSE_POS.y;
temp.z = 50;
vec_for_screen(temp,CAMERA);
vec_set(player.x,temp);
wait(1);
}

in this case player will be at the cursor pos and 50 quants front of the camera.

This is what you want to make?


Never say never.
Re: Move Entity with mouse [Re: tompo] #137353
06/22/07 14:55
06/22/07 14:55
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
D
Disaster Offline OP
Member
Disaster  Offline OP
Member
D

Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
Yeah^^
Thank you!!! It works great. This is exactly that i was looking for


mfg Disaster

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