help

You must understand the Game Editor concepts, before post here.

help

Postby savvy » Sun Aug 01, 2010 11:44 am

how do i get an actor to follow the mouse in rotation, as in a turret following the mouse to aim? cos im stumped
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: help

Postby jimmynewguy » Sun Aug 01, 2010 12:37 pm

if you mean rotating to face the mouse then use
Code: Select all
angle=direction(x,y,xmouse,ymouse)/nframes;

But for some reason xmouse and ymouse always tend to be off so your better off making an actor called mouse and on create actor setting it to follow mouse then change the turrent code to
Code: Select all
angle=direction(x,y,mouse.x,mouse.y)/nframes;


EDIT: Put this in draw actor
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: help

Postby savvy » Sun Aug 01, 2010 2:53 pm

ok, thanks
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: help

Postby savvy » Sun Aug 01, 2010 2:56 pm

it still doesnt work
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: help

Postby DilloDude » Mon Aug 02, 2010 2:14 am

jimmynewguy wrote:if you mean rotating to face the mouse then use
Code: Select all
angle=direction(x,y,xmouse,ymouse)/nframes;

But for some reason xmouse and ymouse always tend to be off ...

xmouse and ymouse are screen coordinates. So to use them, use
Code: Select all
direction(xscreen, yscreen, xmouse, ymouse);


In you're example, you're adjusting angle. angle is for movement, and requires directional_velocity.
If you want to adjust the animation use
Code: Select all
double dir = direction(xscreen, yscreen, xmouse, ymouse);
animpos = (int)((dir + 5) * .1) % 36;

This is for a 36 frame rotation animation (for other values you'll need to adjust the numbers.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: help

Postby jimmynewguy » Mon Aug 02, 2010 3:22 am

DilloDude wrote:In you're example, you're adjusting angle. angle is for movement, and requires directional_velocity.

:shock: when i type fast i do weird things, i meant angle to be animpos...but your code is better :D
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: help

Postby savvy » Mon Aug 02, 2010 11:05 am

ok, its still not working. heres the actual thing
Attachments
TD.zip
(5.26 MiB) Downloaded 117 times
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: help

Postby jimmynewguy » Mon Aug 02, 2010 3:16 pm

the animtion of your turrent rotating should start at zero degrees (facing right) and rotate counterclockwise in order for the code to work :)
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: help

Postby savvy » Mon Aug 02, 2010 3:57 pm

o, ok
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: help

Postby savvy » Mon Aug 02, 2010 4:13 pm

ok, now with that done i need to know how to make a bullet travel in the direction of the mouse.
(ive never done rotation code Bfore)
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

TOPIC CLOSED

Postby savvy » Wed Aug 04, 2010 8:22 pm

dont worry, i have it done. -CLOSED TOPIC-
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest