moving target
Blitz3D Forums/Blitz3D Programming/moving target
| ||
I have the most of this already complete... Just a game I developed to learn how to create a missle firing system with tonnes of help from all the Ross' Wolron, Neuromancer et al... But I can't figure out how to make the targets revolve around the gun. I think I set the parent\child thingee okay, but when I move them they only slide off the screen. Rotateentity doesn't seem to wrok either. QUE!!! |
| ||
I looked at the GALAGA type code in the examples but all the variables seem to be written to confuse people. (I think if you are going to submit a program for inclusion in examples your variables have to have better names... IMO) I really just want to rotate them slowly and be able to fire at them. |
| ||
OK no help yet... I can be patient... really! : ) -RZ |
| ||
Try making the camera a child of the turret. You could also get rid of your GOTO (and the THENs) using this adaptation of your update_bullet() function. Function update_bullet() For b.bullet = Each bullet MoveEntity b\entity,0,0,b\speed ; this is my collision modification HERE If EntityCollided (b\entity,1) ; no one would help with entitycollided ;kill = kill-1 score = score+10 ; update socre FreeEntity b\entity ; kill bullet if it hits FreeEntity b\pivot Delete hit.badman Delete b.bullet Else ;Better than GOTO If EntityDistance#(b\entity,b\pivot) > b\range FreeEntity b\entity FreeEntity b\pivot Delete b.bullet Endif End If Next End Function Hope this helps Nik. |
| ||
That certainly works in the bullet dept. Thanks... But I need to figure out how to rotate the entitys around the turret. It is the parent \ child thing and I assume a pivot thing as well... BOTH of which I need to learn more about. : ) -RZ |
| ||
I have to be honest and say that I'm not entirely sure what your problem is. (I can't run the code because I don't have the media (and I'm too lazy to create any)) I don't understand what you mean by this sentence: But I can't figure out how to make the targets revolve around the gun. What targets are you talking about? Please try to be more specific about what targets your are referring to, what gun you are referring to, and what exactly you mean by revolving (I know what revolving means, but I don't know how YOU want your targets to revolve).However, here are a few pointers: I see that you definitely don't need these lines: FreeEntity xo FreeEntity yo FreeEntity zo FreeEntity xo2 FreeEntity yo2 FreeEntity zo2in your PutBadmans function. Those variables contain entity locations not entity handles. You are just freeing random entities which either actually does free random entities in your game or they (the FreeEntity commands) just fail (which is what probably happens 99.999999% of the time). You definitely don't need to set the entitytypes every frame of you game: For hit.badman = Each badman EntityType hit\entit,1 PositionEntity hit\entit,hit\xo,hit\yo,hit\zo Next For hat.badman2 = Each badman2 EntityType hat\entit2,1 PositionEntity hat\entit2,hat\xo2,hat\yo2,hat\zo2 NextDo that when you initialize your badmen like in this For-Next loop: For tt= 1 To 20 hit.badman = New badman ; where did HIT come from... I made it up. I could hit\entit = CopyEntity (badman) ; have used a letter or any word not reserved hit\xo=Rnd(-100,100) ; NOTE " \ " not " / " hit\yo=Rnd(-50,50) hit\zo=Rnd(100,150) ; Since B3D uses both + and - nums I had to use Rnd EntityType hit\entit,1 Next ; That way my badmans are spread out evenly-ish I suspect that this code:: For hit.badman = Each badman PositionEntity hit\entit,hit\xo,hit\yo,hit\zo Nextis intended to not only set the badmens locations but you actually want to use it to UPDATE the badmens locations? If that's the case then you need to add some line in there something like: For hit.badman = Each badman hit\xo = hit\xo + rnd(-.1, .1) hit\yo = hit\yo + rnd(-.1, .1) hit\zo = hit\zo + rnd(-.1, .1) PositionEntity hit\entit, hit\xo, hit\yo, hit\zo NextNote however, that using the above code will just cause them to wiggle around a bit. But since I don't know what you mean by revolve, I don't know how you actually want them to move. |
| ||
Wolron, Your revised type thingees have helped me clean up my code. I appreciate that. How I want them to rotate: Imagine you hold an open umbrella. the metal stem is in your hand. your hand is the gun. The metal posts that support the fabric out to the edges and those little pegs that plug the fabric. Well those little pegs are the targets. Rotate the umbrella and watch the pegs move aroung the center (which is the pole and the GUN) Probably not much clearer... I am going to keep trying. I saw an example a few weeks ago when someone had a camera orbiting around a sun... like that... in reverse. The gun or camera remains in the middle and all revolves around it. -RZ |
| ||
Yes, just place a pivot at the point you want your targets to rotate around, then parent your targets to that pivot. Now you can TurnEntity the pivot to make all the targets rotate however you like. |
| ||
That makes sense... AND I didn't know that... Wow 2 with one help! : ) |
| ||
UPDATE... OK pivot I got it... |