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.

Newcomers DBPro Corner / Need Help with RTS-style movement

Author
Message
Boe
17
Years of Service
User Offline
Joined: 30th Nov 2006
Location:
Posted: 6th Jun 2008 22:31


Hi. I'm trying to make this 3d model to move where I right-click, but:

1. when done so, the camera freezes in place.
2. the model often heads in the wrong direction.
3. It does not seem to stop.

My code for the general loop is above.

Can someone please say what's wrong?
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 7th Jun 2008 16:02
I read a your code,
Because I do not understand the post-part which is not considered to be it, I cannot correct it.

You search "Vectors Don't Bite!" in a forum.
All is explained to there.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 13th Jun 2008 00:45 Edited at: 13th Jun 2008 01:10
1) That's because you made a REPEAT/UNTIL loop without the camera controls in it. You can't do anything outside of that REPEAT/UNTIL when in it.

2 & 3)

Okay. MOUSEX(), MOUSEY(), and MOUSEZ() only generate 2D coordinates (I'm actually not sure what MOUSEZ() does, but you won't need it for what you're trying to do), not 3D ones. As a result, when you tell your 3D object to move to those 2D points it will probably go somewhere completely different from where you wanted because those aren't 3D points. That's where your PICK SCREEN command comes in-- it helps convert those 2D coordinates into 3D ones.

In order to get the actual 3D positions from your PICK SCREEN command, you will need to use the GET PICK VECTOR X() and GET PICK VECTOR Z() commands in combination with the CAMERA POSITION X/Z commands. Try using those instead of your mousex() and mousez() commands (The coordinates you've got in your PICK SCREEN command are perfect so don't change them...)

Boe
17
Years of Service
User Offline
Joined: 30th Nov 2006
Location:
Posted: 13th Jun 2008 02:47


Thanks for the advice so far. #1 has been solved. But problems 2 and 3 still are occuring. Here's the updated Right Mouse Click code, so some one like Sixty Squares can explain what's still going wrong.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 13th Jun 2008 18:02
Try increasing the distance value of your PICK SCREEN command (that's the last one-- you have it at 1). Your camera is about 200 units off of the ground, so try making the distance value somewhere around there (maybe 200 or 400 or something like that). I think that should help.

-Sixty Squares

Boe
17
Years of Service
User Offline
Joined: 30th Nov 2006
Location:
Posted: 13th Jun 2008 19:43
Sorry, but its not helping.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 13th Jun 2008 20:28
In that case I'm not sure. The only other value I'd think to use would be the 3D distance between the camera and object number 1... Maybe someone else can solve this.

Zergei
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 14th Jun 2008 08:00
Try something like this...



Further on my stuff at...
TurboSquid.com
The3dStudio.com

Login to post a reply

Server time is: 2024-09-27 16:32:48
Your offset time is: 2024-09-27 16:32:48