Search the Community
Showing results for tags 'Bullet'.
Found 3 results
Hi, So I can't find a good example or tutorial on how to create a bullet projectile that will fire in given direction and vanish if get off screen or hit an obstacle. On the forum subject of bullets is mostly covered in FPS type game where you would use a raycasting with no visible bullet. Only post that relates to bullet I'm after is http://www.leadwerks.com/werkspace/topic/11941-bullet-hell/page__hl__bullet but to be honest there is no LUA code to start with and there is no answer actually how to go about it. Did somebody tried to do it ? Please correct me if I'm wrong but it looks like Sprite object will be the most suitable for this. Let's assume for this exercise that I got a 'turret' that fires in one direction if I press a button. On that action a sprite is being created from within a turret script (texture, initial position, etc) and is being pushed with eg. SetVelocity. (other ? please correct) 1. Can Sprite be created from within a turret script and have own LUA script attached which will describe potential interaction with the World like collision, Velocity etc) 2. Will that bullet become own entity in the World ? 3. Can it be destroyed/released/nullified from the World ? If yes, how? 4. Is is possible to determine is Sprite visible by the players camera ? (eg. Top down static view on a playing field I'm am still fairly new to Leadwerks but seems that games with shooting mechanics where Raycasting is not a good option as it requires a projectile to be visible and hit not being instant, are not covered too much. Thanks
http://pastebin.com/yQ2jHPii > I put my script on pastebin for better overview. This is the script I attached to a turret . Basic explaination: It ckecks for enemies nearby and alligns itself to them, calls shoot() function once in a while. The Bullet itself is only for the visual. To hurt the enemy, I will later acces the enemy script trough the turret and call a hurt function. In the start funcion I set up an emitter which should look like a bullet flying . I want to know how i properly let the emitter play , and have multiple bullets at one time. ( or just how to play it , i can make the bullet run faster so it would be no problem if it gets resetted). I made an attempt in the Shoot() function, but i cant see anything inside the game. 2 The performance is still a littlebit low, I can spawn ~30 turrets at normal fps and when I spawn more it gets lower (not over time, the more turrets the less fps). I personally think its caused by my computer or lua, but still if you can find anything that could cause less performance please tell.
The picture shows how I set up my turret. http://pastebin.com/vDrh15pd This is the script I attached to the turret. When I am ingame the bullet is still rotated 0,0,0 and only after some time it follows the turret. The turret is looking at the target, which is the enemy. When the turret calls the Shoot() function the bullet flies somewhere but the -z axis on the local (space?). It seems like the muttle pivot is no real child of the turret.