Computer Science Canada How to move and shoot at the same time |
Author: | NeutronX [ Thu Nov 08, 2007 4:01 pm ] | ||
Post subject: | How to move and shoot at the same time | ||
I am making a game that required a car to shoot rockets but I want it to drive at the same time and not just stop. How can I move and shoot at the same time? Here's the code:
Edited by Clayton: I'm about to give up on this... but... USE CODE TAGS!! PLZ HELP! |
Author: | HeavenAgain [ Thu Nov 08, 2007 4:07 pm ] | ||
Post subject: | RE:How to move and shoot at the same time | ||
you'll better edit this code before a mod comes here and go crazy again (they are on a roll these days ![]()
and i think this have something to do with Input.KeyDown but i could be wrong ![]() Edit: oh and if left arrow key is pressed and s is pressed, that if statement should be and instead of or |
Author: | LaZ3R [ Thu Nov 08, 2007 5:29 pm ] |
Post subject: | RE:How to move and shoot at the same time |
Your code needs some revamping... You currently have it so that the player has to HOLD arrow keys to control the location of a bullet. If I hold RIGHT ARROW for 2 seconds and let go, the bullet will stop moving. You also for some reason have it setup so that you are always on the location of the bullet because if I hold right, the x cord of the bullet will increase by 5 but so will the location of the car in this case. What you should do is go through your code line by line and make sure what you want it to do makes sense. |
Author: | Zampano [ Thu Nov 08, 2007 6:17 pm ] |
Post subject: | Re: How to move and shoot at the same time |
Use processes! You probably have heard of procedures; processes are the same except they run at the same time as other processes. This would allow you to have a process for shooting and another for driving run concurrently. Look in on processes in F10. |
Author: | Saad [ Thu Nov 08, 2007 6:58 pm ] |
Post subject: | RE:How to move and shoot at the same time |
I suggest you not use processes and look into Input.KeyDown, processes are not usefull is this situation |
Author: | Zampano [ Thu Nov 08, 2007 8:04 pm ] |
Post subject: | Re: How to move and shoot at the same time |
You know better than I the best method. If there is an efficient way to do it with just Input.KeyDown (more complex visuals are difficult in a loop that relies on the activation of an if) then you should do that instead of using processes. Processes may be convenient sometimes, but they are troublesome even more often . . . |