Hi
- I would like to know how to code - when the ball hits a wall its hp will decrease
- I’d also like to know if there’s some1 willing to help me mutliple times since coding is very new to me and im so noob.
I do watch the videos on youtube and read on unity
Help is very much appreciated and thankfull in advance.
Best regards
Valéry
Start some reading here, especially the “Script actions taken on collision” section:
So most likely you’ll want to use the OnCollisionEnter method which is automatically called on a collision. Then you’ll probably want to verify that what you have collided with is a wall, probably by checking for a wall script or something you have on your wall gameobjects that you can use to identify them. Then if it is confirmed you’ve hit a wall, then you decrease your HP. Note that OnCollisionEnter is called for collisions with anything, even things you won’t necessarily want to have HP decrease, which is why you need to verify it is a wall first.
1 Like
Thank you very much! I’ll try to figure out myself coz already hav 3 questions after reading your post…
Also atm I’m watching this:
https://www.youtube.com/watch?v=gzXtfsezXWo