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 Discussion / Confusing 'position object' problem...

Author
Message
Fred Not Bob
18
Years of Service
User Offline
Joined: 16th Sep 2007
Location:
Posted: 16th Sep 2007 09:35
Perhaps some kind soul can bring peace to my tortured mind....okay, enough melodrama .

I've been tinkering with the RTS Demo in DarkBasic classic, and having some success: the model I'm using (the Beach Bug) is responding to the mouse, and it's facing the proper direction (though initially, it was moving backwards everywhere!).

The problem arises when I attempt to move the car. Currently, the movement code is laid out like this:



The model moves to the destination, and then (one out of every three or four times) continually 'flickers' as though the car is rapidly turning 180 degrees.

The car model is loaded thus:



I've tried setting the car's 'Y' angle to match the direction in which it's moving, and I've tried fiddling with the 'desy#' and 'object position' integers near the end of the first snippet.

I suspect that it has to do with setting something here:



However, 'pointing' the car again doesn't fix the problem, nor does adding a 'yrotate' command.

Now that I've thoroughly confused you all with my sleep-addled meanderings...

Is there anyone out there that can give me a nudge in the right direction?
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 16th Sep 2007 12:32 Edited at: 16th Sep 2007 12:33


can you use the colons like that? it's the only thing I can think of, but wouldn't you have to do



Not too sure sorry, but I think the then statement only applies to the "point object ..." bit; the colon treats the object movement as if it was an entirely new line and therefore it is no longer included in the if...then... statement.

I might be wrong though

http://jamesmason01.googlepages.com/index.htm
Fred Not Bob
18
Years of Service
User Offline
Joined: 16th Sep 2007
Location:
Posted: 16th Sep 2007 20:38
The colon does act as a 'new line' break, but that shouldn't be too big of a problem, as when the model moves, the 'then' statement is already finished and done with.

It does raise a good point; I could stand to clean things up a bit, so I'll get to it after I check my e-mail .

Perhaps the 'then' statement is confusing the program.

Might the code be 'pointing' the car to its *next* destination, based on where the cursor is *afterward*?
Insert Name Here
19
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 16th Sep 2007 22:17
Not related but...
Quote: "Perhaps some kind soul can bring peace to my tortured mind....okay, enough melodrama "

I like this guy.

............................
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 17th Sep 2007 21:23
but doesn't your car want to stay still after it reaches it's destination? otherwise it will keep moving, spinning round to reorientate itself towards where it's headed, and move back again

http://jamesmason01.googlepages.com/index.htm
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 17th Sep 2007 23:19 Edited at: 18th Sep 2007 00:18
@Fred Not Bob

[EDIT - New]
Looking back at your code, it could be that because your car is moving in increments of .9 that it may never be meeting the distance requirment of .2 . If that is the case, it will keep flickering as it moves a little then points back at the destination. Try increasing
if d#<0.2
des=0
endif

to 1.8 (twice the distance the car would move in one iteration) and see if that helps. Then slowly reduce or increase the value until the car continues to respond 100% of the time.

[Old]
Hello,

Well one thing I noticed in the first snippet



this line:
point object 4,desx#,0,desy#

I don't know if the variable desy# is meant to be a z direction or a y direction but you have desy# in the z parameter for the POINT OBJECT command. If it is meant to be a z position, then just for clarity, maybe all occurences of the variable desy# should be changed to desz# - unless there is some reason to keep it named desy#. Because later, you are interchanging z# variables with it. Just seems a bit confusing...

Also, if the y value is set to 0, the object will be pointing down if it is above 0 and up if it is below 0 - probably not what you intend.

In general, when using the POINT OBJECT command, it's a good idea to know which plain you want the object that is pointing to be on. What I mean is, if you are driving a car and it is pointing somewhere in 3d space, the actual direction you point the car in will be an x and z direction. The y value of the car won't change unless you are going over a cliff, splashing into a lake, driving up a ramp, etc.

So, if you are on flat land, you want to maintain the cars y position and point to some world x and z so the command might look like:



Now if you actually have to point the car up or down, then the y value might be in terms of world coordinates as well instead of the cars own y position.

Here is an example of moving a cone through waypoints. Once it reaches one, it points in the direction of the next one. Maybe it will help.



Enjoy your day.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 18th Sep 2007 00:53
Quote: "can you use the colons like that?"

Yep, it acts kind of like a hidden line tagged on the end that is only executed if the original statement is true.
Try reading that out loud in one breath

In programming, nothing exists
Fred Not Bob
18
Years of Service
User Offline
Joined: 16th Sep 2007
Location:
Posted: 18th Sep 2007 05:04
Quote: "is the case, it will keep flickering as it moves a little then points back at the destination. Try increasing
if d#<0.2
des=0
endif
"


Yup, that got it! Thanks, I was very very stumped.

Quote: "I don't know if the variable desy# is meant to be a z direction or a y direction"


From what I can determine, the 'desy#' variable is used to check if the car's reached its destination, so that it'll know to stop.

Anyhoo, on to the fun of camera-ing and collision-ing....

Thanks again!

Login to post a reply

Server time is: 2026-07-06 11:07:35
Your offset time is: 2026-07-06 11:07:35