Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Hey guys I gotta n00b control question LOL

Author
Message
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 6th Jul 2003 06:41
I'm writing a third person right now, and I want the camera to dictate the direction of movment and such like scrolling the mouse left makes the camera turn left and vice versa and same for up down, and an invert cam option, I'm trying to use mousemovex and y in conjunction with mousx and y but I'm getting some bad results I'm using proper syntax, if anyone has a snippet on how I can do this better I'd love to see it, (you'll get credit too, if ya care bout that!) LOL

Wayne
AIPX Rocks
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 6th Jul 2003 06:54 Edited at: 6th Jul 2003 06:56
I have tried this using sin/cos, but have had bad results too. A better way is to make a hidden object at the players location, then rotate the object based on the mouse (i.e. rotate object 1, mousemovey(), mousemovex(),0), then use set camera to object orientation.
Like this:



Forgive me if it dosen't work; I wrote it off the top of my head.

It's not perfect, but I works ok. If someone has a better method, please post it.

"All programmers are playwrites and all computers are lousy actors" -Anon
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 6th Jul 2003 07:09 Edited at: 6th Jul 2003 07:11
well, I want the player's x,y,z to act as the pivot point for the cam, and the cam to always point at the player (That part is easy! lol) it's just the making the cam understand the mouse movements.

Your code was more like the cam is the eyes of the player, when I want it third person, and the cam to pivot around the player a few "feet" away.

Thanx for the quick response tho, I hope I cleared the smoke.
LOL
Wayne

AIPX Rocks
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 6th Jul 2003 08:31
Well here is my do loop, with the code, hope somebody has an answer the mouse will veer the cam up and left but not down and right......


Wayne

AIPX Rocks
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 6th Jul 2003 08:31
do
paste image 10,object screen x(10),object screen y(10)
ink RGB(150,60,60),0
set cursor object screen x(10)+40,object screen y(10)+30:print health
paste image 11,object screen x(10)-30,object screen y(10),1
ink RGB(100,150,80),0
set cursor object screen x(10)-40,object screen y(10)-10:print rounds
paste image 12,400,200,1




set cursor 0,0
print screen fps()
print
print " ";px#
print " ";pz#
print " ";height#

a=wrapvalue(a-1)

color backdrop RGB(0,0,0)


hide mouse
oldmx=mousex()
oldmy=mousey()



px#=object position x(10)
pz#=object position z(10)

if leftkey()=1 then yrotate object 10,wrapvalue(object angle y(10)-5)
if rightkey()=1 then yrotate object 10,wrapvalue(object angle y(10)+5)
if upkey()=1 then move object 10,1
if downkey()=1 then move object 10,-1

print mousemovex()


cs=100001-intersect object(1,camera position x(),100000,camera position z(),camera position x(),-100000,camera position z())

if mousemovex() < 0 then yrotate object 10,wrapvalue(object angle y(10)-20):mousemovex()=0
if mousemovex() > 0 then yrotate object 10,wrapvalue(object angle y(10)+20):mousemovex()=0
if mousemovey() < 0 then ch=ch+1
if mousemovey() > 0 then ch=ch-1
if ch > 20 then ch=20
if ch < cs then ch=cs
if mouseclick()=2 then move object 10,1
if spacekey()=2 then move object 10,-1







px#=object position x(10)
pz#=object position z(10)
sm=100001-intersect object(1,px#,100000,pz#,px#,-100000,pz#)
if sm < -7 then swim=1
if sm = -7 then swim = 1
if sm > -7 then swim = 0
if swim=1
height#=-7
endif
if swim=0
height#=100001-intersect object(1,px#,100000,pz#,px#,-100000,pz#)
endif
print swim


position object 10,px#,height#,pz#
set camera to follow px#,height#+3,pz#,object angle y(10),12,ch,5,0
point camera px#,height#+4,pz#
set light to object position 1,10




position light 1,px#,height+2,py#
scroll object texture 5000,0.0001,0.0001
scroll object texture 2,0.01,0.001
scroll object texture 4,0.01,0.01
scroll object texture 6,0,-0.05

fastsync



loop

AIPX Rocks
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 6th Jul 2003 09:55
ok you know what i figured out something actually kewl, so I'll roll with it, if you still wanna reply go ahead, but I'm happy with what I've come up with.

(And so will you when you see the demo. LOL)

Wayne

AIPX Rocks
anakin
23
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 6th Jul 2003 11:00
Did you add the ability to jump? I've been using a few techniques but was curious what other people are doing...

Anakin
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 6th Jul 2003 12:50
Nah, this is a rogue spear/tactical kinda game, I'm leaving out the jumping because it doesn't really fit, but there will be the ability to roll and dodge.

AIPX Rocks
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Jul 2003 04:47
Did you even try my code? Mine is the view of the camera around the player. I don't know too many people who's eyes rotate around thier head. Whatever. Glad you found a solution.

"All programmers are playwrites and all computers are lousy actors" -Anon
Wayne
23
Years of Service
User Offline
Joined: 3rd Jan 2003
Location:
Posted: 7th Jul 2003 05:24
Andrew, I don't what it looks like over there, but the cam's pivot point was in itself not around the player..sorry..

Wayne

AIPX Rocks
andrew11
23
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 7th Jul 2003 06:17
You have to position object 2 (the hidden object) at the players position.

"All programmers are playwrites and all computers are lousy actors" -Anon
shwuckie
23
Years of Service
User Offline
Joined: 9th May 2003
Location: Australia
Posted: 8th Jul 2003 20:30 Edited at: 8th Jul 2003 20:33


its a bit rough, needs a bit of fine tuning and limiting etc, but this gives ya the idea, this allows the view to move faster or slower depending on how quick/far you move the mouse.

optic blast! megablast! have a blast!!

Login to post a reply

Server time is: 2026-07-18 07:31:07
Your offset time is: 2026-07-18 07:31:07