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 / Here we go again... '3d RTS movement help!' heh... please???

Author
Message
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 10th May 2003 19:42
Hello everyone... I was bored yesterday night and whipped up a piece of code I liked. Basically, the camera hovers above the player; if you move your mouse over a player or enemy (read: immoble sphere) it shows said object's label. Great. Now I want to be able to move my player.

I know how to detect if the mouse is over or has clicked on an object, that's easy with the built-in commands. The problem is, I want to be able to get a point in space directly under the mouse cursor that is not dependant on an object being there-- I'm using big objects for the ground and I want this to be exact.

All I've managed to work out is something that determines the difference between the object's screen position and the mouse's screen position, and translates it into 3d space. But I don't think this is the way to go for 2 reasons:

1- Ideally I want to be able to tilt the camera a little, and this relies on it being fixed AND the resolution being the same (I can live without it if I must, though)

2- It's inacurrate! Very much so in fact. It's okay if I'm only around 80 pixels around the player, but after that the target spot begins to go wildly away from what I'm looking for.

I've looked around on the forums and browsed through several code snippits but all I've found is code for actually selecting objects.


Furthermore, what's wrong with this code piece here?
if playerposx#playertargetx#-40 and playerposy#playertargety#-40 then haveatarget=0

It should set haveatarget to 0 if the player is within 40 3d squares of the target space. I've done a lot of testing to see what's going wrong, and it appears that all of it works except for the final check, which never returns a 1. Thus my object just keeps on moving. Sorry if it's an obvious problem, I'm rusty as an Minoan cogwheel.

Thankee...
--Mouse

Famous Fighting Furball
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 10th May 2003 21:59


This works with me and will place object M at the mouse's position.

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 10th May 2003 22:02
Thankee kindly, I'll try that out...

--Mouse

Famous Fighting Furball
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 10th May 2003 22:09
Zoykes! Why didn't I think of that? It works perfectly! Much obliged, friend !

--Mouse

Famous Fighting Furball
Ian T
23
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 10th May 2003 22:15
Ah, drat, the near-the-target code still isn't working. I wouldn't mind if I knew why. Well, I'll just go at it another way...

--Mouse

Famous Fighting Furball
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 11th May 2003 19:06
No problem

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....

Login to post a reply

Server time is: 2026-07-11 13:57:54
Your offset time is: 2026-07-11 13:57:54