- Home /
Different scores given at different angles of a collider
Hi everyone, I'm fairly new here and trying to create a game while learning the ropes. Currently I'm trying to create a 3D tree chopping game with different sides of a tree giving different scores for chopping.
I am wondering if there is anyway for colliding with my tree (3D) in a radius. At different angles giving out different scores. (Imagine like a pie chart) with different sections giving a (Good chopping spot,Bad spot and 1 shot tree down) as rewards for finding the correct angle to chop the tree?
A friend told me to work with comparing world position of the tree vs the players world position. I am not sure how to do that and wondering if there's a better way to go for it.
That 'd need more info. How do you define the right angle? Is it a vector from center of tree to edge of tree? is it a plane on the tree? Whatever the way, one pointer would be to figure out the angle between that initial perfect cut and angle of attack of the tree. Then with cos(angle) you can get the value. if the cut is perfectly aligned, you get 1 (that you can multiply by a factor to give a score). As you get closer to 90 degrees, it will decrease towards 0.
You can reduce the pan of cut by multiplying the angle. If you only want to cut to 45 degrees, then
score = cos (angle * 2) * multiplier;
Answer by Zodiarc · Mar 08, 2018 at 01:27 PM
You have the information from where the "chop movement" started. Using collider.hit.point you can get the point on which the axe has hit the tree.
With this you have the vector of the movement (swing start - collider.hit.point). with this information you can calculate the angle between the swing vector and the ground (for example the (1,0,0) vector if you're looking at the tree in positive z direction).
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Why is transform.Translate not working? 1 Answer
How a rotating sphere can rotate all the objects on the surface aswell? 1 Answer
Trigger not working 2D 1 Answer