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 / Animating and Shooting

Author
Message
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 7th Sep 2005 20:29
Ok, I have made a model of a Harrier Jump Jet with missiles and machine gunes attached to it. What I need to know is how do I make the missile fire off by its self without the Harrier? And the machine guns which look like cilinders, all they need to do is rotate the outer shell. I have made seperate objects for the missile and machine guns, but dont know how to make it so when 'space bar' is pressed it fires. Im sure that the actual tracking of the missile will have to involve some AI so i will come to that later.

http://www.Bevansfunbox.com
Silent Knight
19
Years of Service
User Offline
Joined: 25th Jan 2005
Location: In Your Mind
Posted: 7th Sep 2005 22:14
although im not providing any code to do this (i dont know how anyway) you could have a line that looks like this


and define the _shoot_gun subroutine in a later part of the code.


Try looking at the swarm source code for shooting sequences. it is in a subroutine like that too.

Version--DB Classic
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 12th Sep 2005 22:55
Do i need to attach the seperate objects under the wing? I have 2 models, one with the weapons already attached and one with out the weapons and i have got each missile and machine gun as a seperate object, and i figured i needed to attach it to the wing which i dont have a clue how to position it in the correct place.

http://www.Bevansfunbox.com
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 13th Sep 2005 05:48 Edited at: 13th Sep 2005 05:50
Well this is quite complicated (for a new user) but it would be done like this.

Im not going to post much source code as i want you to actually have a challenege.

First what you would need to do is take the plane without the missiles already attached.

Then you need to load the missiles and place them according to the jet.
Basically you need to say

That would give you a missle pos under and to the side of the jet. You can position the missle there.
Sample code would be something like this


That would be a function to position the missle under the jet at all times. Now i did not include anything to deal with the fact that if the jets angle changes then the missles angle should change too. Thats your job.

Now what you need to do is call a your version of that function when the missle is docked in the jet. When the player tells the missile to fire, you want to stop calling the function, and call a seperate function that moves the missle forward untill it eaither goes too far off the screen, collides into an object, or what ever else it should do. Once it has done that you call the Position Missle function again so that the missle is position back underneath the jet for refire (if he has unlimited), also you may want to have a wait time for the missle to restock but that is up to you to code.

Hopefully that gives you an idea on how to do the missle code. By the way when i say use function you dont have to. It can be a Gosub, or a while loop or whatever.

Just post if you need some more help

http://img96.exs.cx/img96/2382/sasa.gif
around here.. normal's just a setting on a hair dryer
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 13th Sep 2005 23:35
Well what i have done is i have made the missiles a limb and glued it to the aircraft. That way i can hide it when the fire key is pressed and create a new missile which can be fired in the limb's position, and then after 10 seconds or so the missile will reapear/re-arm.

Thank you for helping.

http://www.Bevansfunbox.com
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 13th Sep 2005 23:51
very nice. i didnt know that you knew limb commands. The only problem with your approach is that you have to reload the missiles, and that will slow down your program.

It saves memory to actually release the missles and once they are done with their loop just reposition them where they need to be. But ofcourse its up to you.

If you do intend to keep the missles as a limb, make sure when you create a new missle use the clone object command. That will just copy the object in memory instead of pulling it from the HD. Saves memory.

http://img96.exs.cx/img96/2382/sasa.gif
around here.. normal's just a setting on a hair dryer
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 13th Sep 2005 23:52
What would be the best way to create a cross hair? I need to make the machine guns shoot at it and the missiles and it needs to go on for ever, or a very very far distance. The red cross in the picture shows a rough place i would like it, anyone got any ideas?

http://www.Bevansfunbox.com

Attachments

Login to view attachments
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 13th Sep 2005 23:55
I figured that it would take alot of work to make the missiles to actually stay in the same direction as the plane is when moving around, i would have to do the x,y,z axis on it, and making it a limb would be an easier alternitave.

http://www.Bevansfunbox.com
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 14th Sep 2005 01:14 Edited at: 14th Sep 2005 01:17
well actually it would not take a whole lot of work to keep the missles positioned relative to the plane. It takes just as much work as to keep the camera behind the plane as it does to position the missles. All you need to do is position the missiles relavtive to the Plane.


I think that should do it, but im kinda too sleepy to test in DBP.

To do the crosshair one solution would be too paste an image in the middle of the screen that looks like a cross hair. Then create an object (small little cube) and hide it (hide object). In every loop position that object say 30 away from the plane. and at the same Y and X position. Then when the missiles shoot, just point the missile at the little hidden cube, and when the move forward (move object) they will automatically move towards the "crosshair".

Also if you do the above, you may want the missile to turn towards the crosshair instead of just launching and automatically be pointed at the crosshair. To do that use the Curve Angle comamnd. That way you can curve the angle of the missile towards the crosshair.



that will turn the missile towards the box as it flies.

Remember to experiment.

Hope that helps


around here.. normal's just a setting on a hair dryer
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 14th Sep 2005 01:33
Well i dont have to position the missiles, when i made the model, i positioned the missiles under the wings and just exported them where they are, so if i load the object, it will load in that place. Would i still need to find the x,y,z for it?

http://www.Bevansfunbox.com
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 14th Sep 2005 01:56
well if you load the plane with the missiles already attached what are you going to do when the player launches the missile how will you hide the missile if it is part of the plane model?


around here.. normal's just a setting on a hair dryer
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 14th Sep 2005 20:02
No, what i mean is on the plane that i made, i made seperate objects for the missiles, positioned them where i wanted them, selected them and exported them as seperate objects, which means when they are loaded into dark basic, the objects have not been exported in the cetral position so it is already positioned under the jet wings for me without having to put in any positioning commands.

http://www.Bevansfunbox.com
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 14th Sep 2005 22:15
Ok, i have the missiels in position and fixed as limbs, i am able to hide them but what i need help on now is this.

When i press the spacebar, it...
Hides object (limb)
Clones object (missile)
Move object blah blah blah (will get to the moving away later)
Show object (limb)

What i have a problem with is when the space bar is pressed, it will clone more than one missile because of the time that u have it pressed down, (even if you tap it quickly) which then creates an error saying object already exists. I then thought to myslef I have to use the For b=50 to 100, Next, which i think will let me clone a missile with object number 50, another for 51, another for 52 and so on, but i have no idea how to do this. I also need it so there is a waiting period so it doesent launch 30 missiles in the space of 1 second, and the wait command makes everyting wait so that cant be used.

http://www.Bevansfunbox.com
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 15th Sep 2005 00:58 Edited at: 15th Sep 2005 01:02
okay to fix the spacebar problem i made an example





you can copy that into dbp and run it, it basically "fires" a missle in text and shows you two ways to make it so that you can fire a missle and then wait (for a certain time, or release spacebar) and then you can fire again.

Now for your Creating to many missiles i would do something like this



that should clear things up, but its up to you to implement the code so that it works with your game.

Hope that helps
post if you need more help.


around here.. normal's just a setting on a hair dryer
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 15th Sep 2005 01:31
Cool, thanks for helping me out. The code for the example didnt work and when i put in the code in the snippet, it just froze when i hit the space key.

http://www.Bevansfunbox.com
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 15th Sep 2005 02:18
are you using DB, or DBP?


around here.. normal's just a setting on a hair dryer
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 15th Sep 2005 02:28
Dark Basic Pro

http://www.Bevansfunbox.com
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 15th Sep 2005 04:20
Okay, i am too, i dont know whats wrong because i tried it on my computer and it works fine..what do you mean by freeze cuz whats supposed to happen is it should sit in Reloading for 3 seconds and then let you hit enter once again (if you choose option 1 that is). Do you have upgrade 5.8?


around here.. normal's just a setting on a hair dryer
Ad87am
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: England / London
Posted: 15th Sep 2005 19:29
Yeh i have the 5.8 Update. This code -
Didnt work, it just freezes everything. I can still exit it without it crashing or locking up tho.

http://www.Bevansfunbox.com
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 15th Sep 2005 23:26
well are you sure its forzen because what it is supposed to do is hit space and then the words change to reloading then you gotta wait a bit before it changes back (btw i think we can get allot more done if you contact me on MSN -Gokz1000@gmail.com or aim : Gokz1000


around here.. normal's just a setting on a hair dryer

Login to post a reply

Server time is: 2024-09-24 03:16:41
Your offset time is: 2024-09-24 03:16:41