- Home /
Object as far Z as it can
I've thought of a targeting system, in which an object is in the center of the camera. All bullets face that object when instantiated... Now what I'd like to know and can't find anywhere is how to make this object instantly go as far z as it can before colliding with something. How would I achieve this?
Well I get that much, I'm currently using a raycast to see if there's anything in front of it... But how do I make it 'stick' to the object it detects?
Well. With the raycast you get the collider that was hit. You can then put the object at the collision point $$anonymous$$us the extents of both objects along the normal of the collision point.
Well I don't have to align it to the normal cause it doesn't really have to 'stick', it's objects z position just needs to be at the collision point. I've tried hit.distance and hit.point.z already, hit being the RaycastHit, but this doesn't seem to get the wanted effect.
Do some drawings or diagrams of what you want, because I don't get it. Sorry.
Your answer
Follow this Question
Related Questions
Ease in transform.LookAt() - keep other target within camera boundaries 1 Answer
How to make an object to look at Raycast Hit Point? 1 Answer
How to change use transform.LookAt to make the bottom of an object look at something? 0 Answers
Target distance would only update closer 1 Answer
Decrease distance between 2 objects 3 Answers