|
I have some troubles with shooting, so just checking if I am doing this right. So player with controller should be attached shooting script that shoots and has lines to apply damage to hit objects. All the objects (enemies) have a script that sets their life and kind of a receiver that checks if damage is sent from shooting script and it applies damage then. Or there are other ways to do this? Thanks
(comments are locked)
|
|
That is a good way to do it; the shooter sends out a raycast, and sends a message to whatever it hits which calls a function to apply damage (the enemy has a function to apply damage, which is called by the shooting script when it hits). Great to know I've done it right. I fixed my scripts and they work like they should now. I have 2 correct answers to the question. But I marked 2nd as a true, just because I learned some important stuff there. Thank you, I'm happy to know I've done it right.
Feb 25 '10 at 06:52 AM
Dima Antonov
(comments are locked)
|
|
you can do this in many ways. you should create a shoot script for the player. for damage you can create a damage script for your bullet or attach the code to shoot script or create a damage script for enemies. having a damage script for bullets is the best approach because you can customize it for different bullets to have different types and amounts of damages. in your bullet you should check if you collide with the enemy or even you can check this in enemy. for example you can tag all of your bullet types with bullet tag and in Trigger functions of enemy check if the other collider has the bullet tag then get the others damage component and execute it's apply damage function. you can do these things in many ways. it's dependent to your project. Yes, I think if I decide to implement more weapons in future, this info is what I need. I like to know general concepts first. Thanks a lot, I fixed my shoot and damage scripts, now all working sweet.
Feb 25 '10 at 06:55 AM
Dima Antonov
(comments are locked)
|
