PDA

View Full Version : Missile code?


Killerzeron
01-06-2015, 12:05 AM
EDIT: Now i made up a missile code...but for now, i got a new doubt. It's below on my plans.

now i know that i need a list if i want my missile to hit the tgt.


Plans:

1) Now what i am gonna do is add a circle , which will act as a range. all missiles will be like a homing missile (just making it a easy flight sim version) so you dont have to wait for a lock on and launch the missile. Now what i need is....the confusion with my if/else. Suppose that i put in all my missiles as a list, so if any of the world's object are in this missile, then the missile can turn and hit the object that was in it's circle. I am confused, i tried using the if () is within () of object then....
Does anyone know how to do this?? i am just so confused....


2) help on this:

i just need some help actually, on the speed one, not using the spacebar for speed, but using the ctrl to move at a constant speed, so what i need help at is that i just want that when i hit the ctrl button the plane moves at the constant speed,but when i hit it again it stops moving.

3)

RavenOfCode
01-06-2015, 12:02 PM
Could you give me the model your working with?

I'm sure I could help you out with it.

Killerzeron
01-06-2015, 10:50 PM
Could you give me the model your working with?

I'm sure I could help you out with it.

hello raven,

Model: MiG-29 (object pack one from here on the forums...)

i firstly apologize that i didnt say what i was working on. what i am currently doing is a flight simulator. while i just get bored so i thought of making a small mini game... which i usually play on my laptop whenever bored at home.

So do you know how to make a missile go behind u? like how real missiles work?

thanks,

i will upload the files later since i am a bit busy now...my apologies.

RavenOfCode
01-07-2015, 04:32 PM
Here is some code on what I think you needed, if you need more or didn't like this I would be glad to do another for you, and I would make it more realistic. Also if you do need more posting a link to a video of what you want would be helpful :)

Hope this helps,
RavenOfCode

Killerzeron
01-07-2015, 10:08 PM
hi there raven,

your code was awesome and i loved it. however if i waant the other missiles to work like that, should i just change the object and pase the code so the other missiles will work like the same in the MiG??

thanks,

Zeron

RavenOfCode
01-07-2015, 10:12 PM
Yes you will need to add other objects and copy/paste the code (via click boards) into another method. And you will need to 'make' the missile aka copy the missileSmoke object and put it behind a new missle.
Best of luck with your game :) I hope to try it out. :)

Killerzeron
01-07-2015, 11:23 PM
Yes you will need to add other objects and copy/paste the code (via click boards) into another method. And you will need to 'make' the missile aka copy the missileSmoke object and put it behind a new missle.
Best of luck with your game :) I hope to try it out. :)

can u do the codes for all my missiles if u can? i couldnt understand the codes and explanation, im not that advanced at dummy and those things xD

Killerzeron
01-08-2015, 12:31 AM
Yes you will need to add other objects and copy/paste the code (via click boards) into another method. And you will need to 'make' the missile aka copy the missileSmoke object and put it behind a new missle.
Best of luck with your game :) I hope to try it out. :)

can u elaborate clearly step by step?

like

first separate the missile from the jet but set the vehicle to the jet,
then just ...
and then...


can u explain like that? After every step kindly add up a , so i can understand better

thanks in advance raven.

RavenOfCode
01-08-2015, 09:38 AM
So what I did was remake the world with missiles that hold the firing code in them. So all you have to do is:
1. Make a copy of the missile
2. Make a copy of the missiles smoke
3. Before shooting the missile play the setupSmoke method (I suggest when world starts play the setup method on the missile using the smoke)
4. When you shoot the missile it can be used on any plane/thing, there are alot of parameters that will pop up and ask you what to use, I think they are self explanitory, whatPlane is the plane your using, missileSmoke is the missiles smoke, dropDistance is the distance it will get dropped, ect.

Hope this helps,
RavenOfCode

Killerzeron
01-08-2015, 10:53 PM
So what I did was remake the world with missiles that hold the firing code in them. So all you have to do is:
1. Make a copy of the missile
2. Make a copy of the missiles smoke
3. Before shooting the missile play the setupSmoke method (I suggest when world starts play the setup method on the missile using the smoke)
4. When you shoot the missile it can be used on any plane/thing, there are alot of parameters that will pop up and ask you what to use, I think they are self explanitory, whatPlane is the plane your using, missileSmoke is the missiles smoke, dropDistance is the distance it will get dropped, ect.

Hope this helps,
RavenOfCode

ah, alright thanks. I am still working on the collision and exploding code

(i have the explosion codes, just need to link the if/else commands with collisions and explosion)

Killerzeron
01-09-2015, 12:10 AM
Hey raven, Thanks for the help. I managed to make up the codes through ur codings. thanks for the help again and ill let you know when my sim is ready.

RavenOfCode
01-09-2015, 09:36 AM
Good job :) And if you ever need help I'm sure me or someone on the forum can do it :)

Killerzeron
01-09-2015, 11:11 PM
Good job :) And if you ever need help I'm sure me or someone on the forum can do it :)

Hi raven,

do you know how to make a restart command? i mean like:

I just want to make the plane go back to its starting position, i dropped a 3d text at its start position. So what i want is that when the plane gets closer to 0.5-3 meters it goes back to its starting position( at the text acting as a checkpoint-like). I tried using if than else but i dont know how to make up the code for it. If it comes in contact within 0.5-3m of any object, anything, it goes back to its start position. And i want this command to be looped forever which i know how to do but, what i did was


I made a method in the MG-29 on it restart command, I used the proximity functiion on the if/else condition( if MiG-29 is within Threshold of object{how to make it as anything?} then do " MiG-29 move to start position>3D text<)

the problem here is, how to make it as anything??

thanks,

Killerzeron

sfunk
01-10-2015, 02:35 AM
Use a world variable. Make it a object variable. Make it a list as well. Put each object you want collision with in the list. That's one way to do it.

Killerzeron
01-10-2015, 06:10 AM
Use a world variable. Make it a object variable. Make it a list as well. Put each object you want collision with in the list. That's one way to do it.

Hmmm...thats basically not the only way. One of my friends figured it out but i cant. A method different than urs. Thats why im asking here. I have everything i need but i miss it out rarely.

RavenOfCode
01-10-2015, 08:48 AM
One thing I would do is make separate methods for the different things the plane is colliding with, as Alice currently can only use the centers of the object to collide rather than the polygons that make up the object.

My suggestion is 2 basic colliding methods:
1.this would be for buildings/other planes/whatever.
Make a method called planeCollide > add ifelse statement > add loopInfinityTimes > add the function if Mig29 is within 1 meter of world > make 2 paramerters, 1 for a distance and replace the '1 meter' with this parameter, the other is an object replace 'world' with this > put the ifelse statment inside the loop > make another method > put a doTogether in it > then place planeCollide into this and us the parameters for the object you want/distance you want. (inside the ifelse statement you can put the code you want for it to reset)

2. This would be for the ground.
Make a method called collideWithGround > add ifelse statement > add loopInfinityTimes > put if else into loop > added the function 'mig29 is below ground' > then put in what you want to happen for when it crashes into the ground > then call this method in the events tab.

Hope this helps, also Alice come with a pre enstalled flight sim, in tutorials, you might want to take a look at that :)

sfunk
01-10-2015, 04:21 PM
You'd still have to make a variable list to use the object parameter if he wants the method to work for all objects this way.


One thing I would do is make separate methods for the different things the plane is colliding with, as Alice currently can only use the centers of the object to collide rather than the polygons that make up the object.

My suggestion is 2 basic colliding methods:
1.this would be for buildings/other planes/whatever.
Make a method called planeCollide > add ifelse statement > add loopInfinityTimes > add the function if Mig29 is within 1 meter of world > make 2 paramerters, 1 for a distance and replace the '1 meter' with this parameter, the other is an object replace 'world' with this > put the ifelse statment inside the loop > make another method > put a doTogether in it > then place planeCollide into this and us the parameters for the object you want/distance you want. (inside the ifelse statement you can put the code you want for it to reset)

2. This would be for the ground.
Make a method called collideWithGround > add ifelse statement > add loopInfinityTimes > put if else into loop > added the function 'mig29 is below ground' > then put in what you want to happen for when it crashes into the ground > then call this method in the events tab.

Hope this helps, also Alice come with a pre enstalled flight sim, in tutorials, you might want to take a look at that :)

RavenOfCode
01-11-2015, 09:27 AM
Or... as I said list the objects he wants to collide with, ie. copy the method into a dotogether and set object to house (or something) and a width for the object.

sfunk
01-11-2015, 09:59 AM
That is just an over abundance of code when you can just streamline it with a list variable.

RavenOfCode
01-11-2015, 12:07 PM
I do realize that and that is what I suggest doing, however he asked for an alternative route, this is the best solution as an easy to understand alternative.

sfunk
01-11-2015, 02:18 PM
Doing things the easy ways isn't always helpful though. To become a better programmer, you have to be willing to try new things to become a better and more efficient programmer. Especially if everyone keeps feeding step by step guides to do exactly what he/she wants, he/she won't learn the basics that will allow them to think of those steps themselves. So it's important to not do too much hand holding when helping. Give them the building blocks they need to build there own path to success.

Killerzeron
01-11-2015, 08:53 PM
Doing things the easy ways isn't always helpful though. To become a better programmer, you have to be willing to try new things to become a better and more efficient programmer. Especially if everyone keeps feeding step by step guides to do exactly what he/she wants, he/she won't learn the basics that will allow them to think of those steps themselves. So it's important to not do too much hand holding when helping. Give them the building blocks they need to build there own path to success.

I am new to alice. However, i understand the codes very well except that everything is a readymade in Alice. Unlike in Java, you need to do everything yourself than in Alice. Alice has everything ready-made like objects, codes etc. If i was not willing to become an efficient programmer or try out new things, I wouldnt be joining or even touching Alice on the other hand. If you're ready to help then its a warm welcome than anything, elsewise. Also, that doesn't mean anything if the person is new while the other is helping and an interuption of sudden "dependancy" That you mean. If you can't bare me, the ignore list exists.

sfunk
01-11-2015, 10:24 PM
My responses are not in a harsh tone. I have been a member of there forums for quite awhile now and always try to help. I was responding to raven's post since the way he is offering is the inefficient way of coding what you want. And I was proposing to raven, instead of telling you step by step how to do everything, just to give you the basic information to get you on the right path. And if you know java or any other coding language, you're taking a step backwards in progress if you're focusing on Alice.

Lastly, creating the object variable under the worlds properties and making it a list that contains all use objects you want detection to occur on is one of the more efficient ways of doing collision in Alice with multiple objects. Using that variable to be called in a collision method would be a good route to go. I have to assume you're not proficient in the English language, so you may not understand the tone of what I am writing as being helpful, but that's what it is.

x2495iiii
01-12-2015, 06:11 AM
Seems like there's a bit of miscommunication here.

sfunk, it's very much appreciated when a senior member helps others to learn Alice, but it seems like Killerzeron is doing fine already. If a user doesn't appear to be responding positively to a suggestion, simply move on. There are plenty of other users in need of help on the forums.

Killerzeron, sfunk was trying to be constructive with his posts. If you don't need his help, simply say so.

RavenOfCode
01-12-2015, 09:40 AM
Seems like there's a bit of miscommunication here.

sfunk, it's very much appreciated when a senior member helps others to learn Alice, but it seems like Killerzeron is doing fine already. If a user doesn't appear to be responding positively to a suggestion, simply move on. There are plenty of other users in need of help on the forums.

Killerzeron, sfunk was trying to be constructive with his posts. If you don't need his help, simply say so.

^

chickentree
01-13-2015, 01:08 PM
One thing I would do is make separate methods for the different things the plane is colliding with, as Alice currently can only use the centers of the object to collide rather than the polygons that make up the object.

My suggestion is 2 basic colliding methods:
1.this would be for buildings/other planes/whatever.
Make a method called planeCollide > add ifelse statement > add loopInfinityTimes > add the function if Mig29 is within 1 meter of world > make 2 paramerters, 1 for a distance and replace the '1 meter' with this parameter, the other is an object replace 'world' with this > put the ifelse statment inside the loop > make another method > put a doTogether in it > then place planeCollide into this and us the parameters for the object you want/distance you want. (inside the ifelse statement you can put the code you want for it to reset)

2. This would be for the ground.
Make a method called collideWithGround > add ifelse statement > add loopInfinityTimes > put if else into loop > added the function 'mig29 is below ground' > then put in what you want to happen for when it crashes into the ground > then call this method in the events tab.

Hope this helps, also Alice come with a pre enstalled flight sim, in tutorials, you might want to take a look at that :)

It seems to me that events in Alice are more efficient and less error prone than infinite loops yet they are rarely mentioned. It there a reason not to put actions in an event rather than an infinite loop?
The types of events make it easy to check for conditions and to turn the events on and off and you don't have to figure out what infinite loop your code is stuck in when it doesn't do what you want.

Mark

RavenOfCode
01-13-2015, 03:52 PM
It seems to me that events in Alice are more efficient and less error prone than infinite loops yet they are rarely mentioned. It there a reason not to put actions in an event rather than an infinite loop?
The types of events make it easy to check for conditions and to turn the events on and off and you don't have to figure out what infinite loop your code is stuck in when it doesn't do what you want.

Mark

True, I have just gotten used to loops. There are alternatives to almost everything in Alice... that's what makes it useful :)