- Home /
Question by
AlexanderSevc · Feb 19 at 11:36 AM ·
collider
Angle/direction from .ClosestPointOnBounds() to transform.position
So I need to find point on collider that is closest to transform.position and find the angle/direction to the same transform.position. It is a part of movement script that slides you down on edge of a cliff and it is supposed to push you in that direction when on edge
void OnTriggerStay(Collider player)
{
if (player.tag != "player")
{
EdgeGroundCheckTriggered = true;
collidername = player.name;
closestbod = player.ClosestPointOnBounds(transform.position);
Vector3 dir = (transform.position - closestbod).normalized;
Debug.DrawRay(closestbod, dir, Color.red);
}
}
This is what I am trying to work with, but I do not even know what it is doing. The "DrawRay" was for visualization, I was hoping it would help but it did not. Please help
Comment
Your answer
Follow this Question
Related Questions
Internal collisions 1 Answer
how to improve the the colliding system 2 Answers
How to catch when object touches other object? 1 Answer
Why doesn't my prefab collide with my map? 1 Answer
Script doesn't find other script 0 Answers