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 / Pivoting an object

Author
Message
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 14th Jun 2003 04:12
This is probably a ridiculous question, but I have been trying for a while now to find a way to pivot an object. For example, I'm trying to have an object that is always at the camera's position and will follow the mouse so that I can aim at something with it. Is there any way to do this?
Dave J
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 14th Jun 2003 07:00
I'm not exactly sure what you mean, but it's possible to pivot objects with the "Turn Object" command. If you mean you always want it facing something then you can use "Point Object" command.

Maybe explain a little more on what you want.

"Computers are useless they can only give you answers."
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 14th Jun 2003 07:30
I'm trying to have a line that matches the camera so I can aim at things with it and "kill" them. Right now, I have it to where it'll follow the camera, but I can't get it to follow the mouselook. I can't aim up or down...all it can do is line up with something. My code is posted.
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Jun 2003 09:20
it would be easier if u made a no media example for people to see the result or perhaps a cut down version of the problem at hand.

MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 14th Jun 2003 10:00
You're probably right, indi. I have created and attached an example of a very simple version of what I'm trying to do. Click the mouse to hide the cube (or "Kill" it) and control the camera using the arrowkeys. Although it doesn't look like it, you do strafe sideways.
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Jun 2003 12:12
blivvy showed this to many moons ago perhaps its of some interest.

similar idea / different method / less code




http://www.lunarpixel.com
http://www.lunarpixel.com/dt/
looking for something? try kangas search..temp mirror site http://www.lunarpixel.com/dbsearch/
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 14th Jun 2003 12:18
What i do is create a dummy object eg.
make object plain 1,1: hide object 1

then i set the dummy object to the cameras position and cameras orientation then i move it into the distance say 1000.

then I aim rockets, bullets etc at this object in the distance which is always in line with the cross hair.

regards,
Ozbot
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 14th Jun 2003 12:23
Something else that may be of interest if you want to check if something is in the cross hairs Say for locking on rockets to an object or just changing the color of the crosshair sprite:

You can model an object which is just a huge 3d line a box that is say (1,1,1000) every frame I set that object to the cameras position and cameras orientation and then (if the object is say 1000 units long) move it 500, reason for this is so that it doesn't detect collission behind you.
I also hide the object so it is not visible.

At this point you have an object sticking directly ahead of you at all time, then just check collision against this object and enemies. works a treat for me...
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 14th Jun 2003 12:41
Sorry another idea,

you could also combine the two suggestions together so if an object is in the crosshairs you find out the distance between the camera and the object that is in the cross hairs then you move the dummy aiming object from the camera that distance, this ensures that bullets don't go underneath or over the object.
regards,
OzBot
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 15th Jun 2003 03:17
OzBot, reguarding your next to last post (the one on sticking an object out in front of you), that is what I am trying to use instead of bullets (to help with lag and for an instant-hit effect). You said it could be done this way on my "Bullets" post, but unfortunately I cant get it to follow the camera's rotation. When I set it to the camera's position and orientation, it keeps appearing above the camera and points downward in a slant, and it won't check collision with anything. Locking it on the camera does the same thing. Am I just doing something wrong?

I have included the code where I make the huge 3d line and the code for the gun control.
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 15th Jun 2003 13:33
Right I have extracted some code from the game I am working on at the moment so you won't be able just to paste it in and hope it works, but you will be able to see how I do things. It might seem a little complicated but it isn't really. I have different bullet states (arrays) so I can do different things with the bullets E.G animate them on impact. I hope you can work out what you need to do based on my code.

If you want to see how my game is so far than click the link to take you to my page and download, so you can see if this is the way in which you want to progress. I still have alot of tweaking to do but you will get the idea of what I am trying to achieve.

http://217.210.154.125/CProject.htm

regards,
OzBot

OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 15th Jun 2003 13:39
line 8:
load object "media\line.x",laser
should read
load object "media\line.x",line

if you want to use my object it is in the media directory called laser.x

Originally it was going to be a laser for shooting but i ended up using it for collision detetction so I renamed all lasers to line for easier understanding in my last post, but not in my game.

rgeards,
OzBot.
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 15th Jun 2003 20:51
I downloaded your game, OzBot, but when I ran it it gave me this:

Runtime Error 1507 - Display using 32 bit is not supported by available hardware at line 14

I use a GeForce 4 MX 420 on a 1.1 ghz (Celeron) HP Pavilion. Oh well, I guess I'll try to visualize what the code does and try to adapt from the visualization. Thanks anyway.
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 15th Jun 2003 21:21
And when I tried your code, it kept telling me that the "next i" at the end of the _bullets for/next loop is out of place. Which is absolute BS. (sigh) I think God doesn't want me to make this game...
OzBot
23
Years of Service
User Offline
Joined: 24th Feb 2003
Location: Sweden
Posted: 15th Jun 2003 22:13
I have changed the zip file, so now it should work.
When I write games I always devolop them so they run well on my machine at high resoltions, thinking that it will run better at lower resolutions, however I didn't put the setting down, so now I have compiled the game at 1024x768 32 bit.
Let me know if still has problems.

Regarding the 'Next i' problem, I have no idea why you might be having that problem. Have you missed a next i somewhere else? Check that all subroutines have a RETURN, sometimes that can cause problems, check that you haven't missed off an ENDIF anywhere in your code. Sometimes error messages like the one you just mentioned may be nothing to do with the area of code you think it is.

regards,
OzBot
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 16th Jun 2003 12:27
Well, OzBot, now I can't run it at all. Or is it supposed to wait a long time at the desktop before it starts up?

About my next i problem, I figured it out. It wasn't supposed to be next i, it was 1 (one) I kept seeing, and being severely lacking in sleep these past few weeks, I thought it was I. In reality, the for next loop used the variable b, and it already had next b in there. However, that still isn't helping any of my problems.

Let me restate my problems, as I have been changing some things around.

In some post, someone gave me a code snippet that he said, with enough adaptation, should work. (Sorry...too tired to remember.)

Anyway, I have tried to incorporate that into my game. Of course, even with all of my adaptation and the re-adjusting and even near-complete re-writing I can still get the bullet to do only one thing: appear and stay static.

Recently, I have implemented code David89's into the game (it is on my "Bullets" post). However, now when I click the mouse I get an Object Already Exists error. I know this cannot be possible, simply by looking through the code. It deletes the bullet at the end of its life, and even if it didn't, the object is being cloned.

If you happen to read this, David89, the object it is saying exists is the object "visible", which on first click is object 1001. The clicks thereafter should make the object 1002, then 1003, and so forth up to my max bullet number, which for testing purposes I set to 10. Then once their life has expired, they are deleted and new objects 1001 - 1010 come in. Yes, I have modified the code a bit, and just now I placed

visible = b+1000
o = visible

in the if mouseclick()=1 and Bullets(b,1)=0 and (timer()-LastCreated) > BulletWait statement. Therefore, it won't do that until I click. Previously, it was doing it before I clicked and may have been causing the problem. I've went ahead and attached the modified _DoBullets subroutine. I've yet to check the new changes to see if they work as I'm deprived badly of sleep (as you can probably tell from my incoherency) and I want to sleep.

OzBot, I was, yesterday, trying to modify the code listed above to my game (get all of the values changed and the like) , and I think now that I was having the "next i" problem there. I'm not sure though...I might've fixed it. I'm really too out-of-it to remember.

I wish there were a Magic Code Fairy that would come to me if I left my computer on at night and fix all of my code up so that it was automatically Quake 5 or Half-Life 3 or something ridiculous like that .

Login to post a reply

Server time is: 2026-07-11 14:56:13
Your offset time is: 2026-07-11 14:56:13