- Home /
hit.transform.position + hit.normal; makes objects float
Hi!
I have some kind of block building thing I made and when I want the highlight thing to appear when I have the mouse over it and I am using this code:
addCube.transform.position = hit.transform.position + hit.normal;
But when I hover over it, it floats above it. I do have all the objects scaled down to 0.1 if that has anything to do with it. If it does, how can I fix it?
Thanks in advance!
I'm not 100% certain but usually normals are unit vectors (length 1) so with this code you're placing the object 1 world unit in front of the collision spot.
@Nose$$anonymous$$ills I see. Do you know how I could make a workaround for this? I am clueless.
Just remove the + hit.normal position, and if your cube has a scale of 0.1 and originally had a height of 1 unit, then ins$$anonymous$$d of that code, just use:
Vector3 newPos = hit.transform.position;
newPos.y += 0.05f;
addCube.transform.position = newPos;
@Evil Tak But what if I want the object to be on all sides?
Answer by flapy-monkey · Dec 23, 2014 at 05:05 PM
simply, two camera for view, deep one for the thing, up one for the cube
Your answer

Follow this Question
Related Questions
What is the reasoning of multiplying by Time.deltaTime 1 Answer
does not work check if dead 1 Answer
Help around an approach to a "Virtual Motion Table" in Unity 0 Answers
Instantiated prefab position 5 Answers
Setting Position of Spawned Prefab 2 Answers