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 / getting in and out of vehicles

Author
Message
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 20th Sep 2005 18:44
right, this source is a basic downed version off my full game. Theres 3 vehicles (Cubes) and a cylinder which is a player character
the cylinder has a movement of 10 when you press the upkey i need some code based on this so when you go within a certain range of one of the cubes and press enter the camera is positioned behind that cube and that cube becomes the player object until enter is pressed again and you return playing as the cylinder leaving the cube where you pressed enter last. I also need it so the speed is changed depending on which 'vehicle' youre in. heres th source

Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 20th Sep 2005 23:02
Why not just attach the car to the player as a limb? That would seem easiest. With the OFFSET LIMB & ROTATE LIMB commands you can make it look like the player is getting into the car and then just move the player and the car will move with him. The speed and rate of turn varibles can be changed depending on the type of car. The speed can be derived from some sort of scale. A simple one is 0 - 90 degrees of a Sine Wave. 90 degree is 1. 0 degrees is 0, so at the begining acceleration is pretty good, then at end of the scale acceleration will be slowed right down and eventually top speed will be reached. rate of turn can be defined by a maximum turn rate and how much the player is trying to turn.
Hope this helps. If you need help with limb commands, then ask.
Yours
Lee
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 21st Sep 2005 18:14
i do need help with limb commands. i understand some of what you've said
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 21st Sep 2005 23:10
Ok,
First thing first, we need to create a limb for the character (who shall be know as eddie from now on) so that a car can be attached to it.

MAKE MESH FROM OBJECT <mesh number>,<object number> `This command will make a mesh from the specified object. A limb needs a mesh so it can be created. And a mesh must be created from an existing object

MAKE MESH FROM OBJECT 1,1

A mesh of Eddie has been created and is Mesh No.1

We can now add a limb to Eddie by use of the ADD LIMB command:

ADD LIMB <object number>,<limb number>,<mesh number>

ADD LIMB 1,1,1 `The Limb will be a mesh of eddie

So Eddie has a Limb (Limb No.1) which was created from Mesh No.1
We now have to hide the limb from view using the HIDE LIMB command.

HIDE LIMB <object number>,<limb number>

HIDE LIMB 1,1

Eddie's limb is now hidden.

So Eddie now has a limb for other objects to be attached to.
So Eddie is strolling down the street, he looks left, he looks right, and oh... whats this?... its a brand new Ford Focus, and Eddie likes the look of that so he strolls over, the Player press ENTER and Eddie walks to the side of the car. The door opens, Eddie steps inside and is ready to drive the car.

GLUE OBJECT TO LIMB <object number>,<second number>,<limb number>

so...

GLUE OBJECT TO LIMB 1,2,1

Which means the car (object no.2) is glued to Limb No.1 which belongs to Eddie a.k.a object no.1


To ensure that the car and Eddie both move and rotate in the correct place and manner, two commands can be used to set the objects up. These are OFFSET LIMB and ROTATE LIMB.
OFFSET LIMB offsets the specified limb relative to the object who owns the limb. Because we have attached the car to this limb, this means that the car will also move releative to the object that owns the limb - in this case Eddie. Once you have worked out the correct x#,y#,z# to use will has Eddie sitting in the driving seat, you will not need to alter them at all.

ROTATE LIMB rotates the limb relative to the object who owns the limb. This means that again the car will rotate with the limb and will stay at that fixed rotation relative to Eddie no matter where eddie is looking. Again once you have worked out the values which ensure Eddie is looking out of the window then these values will no need to be touched as only the object that has the limbs (Eddie) will need to be moved and rotated.
The only thing to note is that once Eddie is in the car, the way Eddie moves is different so that its sort of like driving a car. To ensure this happens you can use a flag
A flag is probably outdated now, but I still use them. I call them useful names like 'IsEddieInCar' and if this flag=0 (i.e. IsEddieInCar=0) then eddie isn't and is controlled normally. If this flag=1 then eddie is the car and the normal controls should be skipped and perhaps the program sent off to another sub-rotuine which will deal moving eddie as if he really is in a car. Make sense?

I notice from your description that you are using basic objects, and all the above that i have said can apply to that, you can attach your cube to your cylinder, and move it around, and expriment with the OFFSET and ROTATE LIMB commands and then move the car around to see what happens. Something to think about for the future is that when you move on to proper models, you can have more limbs. A Car for instance, three limbs, one for each door (3-door model), four more limbs for the wheels, and you can use the ROTATE LIMB command to turn the wheels around the X or Z axis depending on how the car was set up. A person will have many limbs, though you could stick with just the arms, legs and head to make things simpler.
Ok, i know that was pretty extensive, the help files are there and should be used also, but if you have any more Questions pls ask.
Hope this helps

Yours

Lee
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 23rd Sep 2005 23:30
ok ive tried that but it keeps saying `limb doesnt exist`
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 25th Sep 2005 20:12
what do i do now
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 26th Sep 2005 00:16
Sorry about the late reply, I've been busy and even though I have selected the Mailback Enable button, I haven't had any e-mails.
Ok, Limb Doesn't Exist: straight forward error message, it just means you are trying to use a limb thqat hasn't been created.
It would help immensely if you posted the code and the the line number that the error occurs. I would suggest that you look at the help file and list all the commands you have used and check that they are used correctly.
I've just checked an early program that I created. With the GLUE OBJECT TO LIMB Command, try 2,1,1 instead of 1,2,1.
My code suggest that I'm gluing an object to my object's limb.
So its like saying Glue car to Eddie's Limb.

So where:

GLUE OBJECT TO LIMB <Object number>,<Second Object>,<Limb number>

It means GLUE OBJECT TO LIMB Car,Eddie,Limb No.1

Make sense? It confuses me because if we consider a body, I always think that the Second Object should be the arm and not body!

So after all my mumbling, the computer doesn't think the limb exists because it is looking for a limb to exist on the car - which obviously doesn't as Eddie is the only model to have a limb.
If it still doesn't work, Copy & paste the code and I'll work my way through it
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 26th Sep 2005 23:27
ok i've done what you've said about rearranging the number order heres the code


theres no errors now but what i need to do now is when you press the enter key again the cube that was attached to the cylinder "eddie" gets unglued from eddie near that position but still able to get glued to eddie again if the enter key is pressed. Ive used collision and key commands together for gluing the two objects since that is the simplest command i can think of
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 26th Sep 2005 23:33
ive tried an unglue command
unglue object 2

but when i do so object 2 goes bigger then it should and leaves object 2 covering eddie and the collision prevents "eddie" from moving
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 13th Oct 2005 22:37
our you going to reply?
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 14th Oct 2005 08:14
Can you this with models I am trying to do a get in and out vehciles using 3D models and I want my player controls to be different from the vehicles (the player controlled by keyboard and mouse the vehicle can be controlled by both keyboard and mouse or joystick controls)
Now I know about shapes but I have a hard time getting the models to do the same thing? it is possible with models?

And is it possible to also do it like this the player goes up to the car and can get in without using a key but to get out of the vehicle he uses a key.

Sorry I don't mean to hijack this thread but I have been working on this problem for months now
Opposing force
19
Years of Service
User Offline
Joined: 10th Aug 2005
Location: England
Posted: 25th Oct 2005 13:19
am i ever going to get a reply
devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 28th Nov 2005 02:49
I hope so. I'd like to have vehicles in a game too....

verydevastating.com

Login to post a reply

Server time is: 2025-05-23 02:39:17
Your offset time is: 2025-05-23 02:39:17