How to make paint characters shoot each other?
Hello everyone,
I'm a total newbie when it comes to Unity. Anyway, I'm doing this game and I've created the terrain and everything but now I need a bit of advice. This is a 3rd person shooter game and my characters are men made of paint. I've used the 3rd person controller and models offered as standard by Unity because they're perfect for the look I'm going for and what I need. But, I want to make these characters shoot each other with projectiles of paint that come out of their bodies. I also want them to color the bodies of their enemies when hitting them, or the terrain if they miss. Can you please give me any advice on how to do this?
I hope I haven't offended you with my stupidity and thanks in advance for any help!
I hope I haven't offended you with my stupidity
No. Although for simplicity, it would be preferable if you had thought of your problem as sub-problems and focus on solving one problem at a time. I don't want to write an essay of why, the tl;dr can be summed up as:
One small question is likely already asked/answered.
One small answer closes question.
To me, it sounds like you are asking three things for example;
How can I shoot a projectile?
How can I detect when the projectile hit something?
How can I apply an effect of paint splash on an object?
The answer to each question can be a multistep answer, and you might not yet even have a clear idea of what you want to happen, how difficult it is, or what alternatives there are. As you can imagine, a "complete answer" for your "complete question" in this form can get verbose, tricky to answer because person A perhaps know about solving step 1 and person B know something about solving step 3. Neither person A or B want to reply, because they know they won't be able to answer the complete question.
Answer by Statement · Nov 07, 2015 at 12:42 AM
I'll give you a high level overview of what you can do.
To shoot a projectile, you need a direction to your target and then either move a slow moving object object with a rigidbody/collider in that direction or cast a ray for instant/rapid fire, or a combination of both. To spawn a projectile, either a prefab is instantiated or an object is reused from an object pool for performance reasons. If you use a game object to represent your projectile, then it need to keep moving. You could just add a force to the rigidbody, or write a script that control the path exactly how you want it.
To detect the projectile hit something, typically you'd just query Physics.Raycast for instant/rapid fire type projectiles, to see what object is hit. Or use OnTriggerEnter or OnCollisionEnter for slower moving projectiles, where the projectile handles collision response after it's been fired.
Once an object has been detected, you'd respond to the collision by applying an effect to the object that represents paint. I don't know what specific effect you had in mind, but a simple "to get started with anything" could be to change the color of the objects material. To do this, get the renderer(s) of the object and modify the renderers material color. Obviously it would not look very nice to color the entire terrain but it can be a first step. More accurate solutions use decals. Even more accurate solutions could use shaders to make paint "flow" or "drip" over the bumps and normals of the bump map. For ideas, check out how Overgrowth did blood effects.
Thank you so much! This is really helpful to me. Your help is much appreciated.
Your answer
Follow this Question
Related Questions
My enemy AI shoots projectile only to certain degrees. Apparently related to transform.position? 0 Answers
How to fire bullets from multiple guns at the same time? 2 Answers
Don't know how to end animation of shooting ! (code) Please help ! 0 Answers
How to access a animation transition paramater bool via script 2 Answers