Hi, I made a model, UV mapped it, saved it as an .OBJ, and imported it into Unity(along with the texture). I made a material for it, added the texture to the material, and added the material to the object(model). However, the UV cords are all messed up. It doesn’t look anything like it did in my modelling program.
Did I screw up somewhere in the importing of my assets? Or what?
P.S. I didn’t really know of any good tags to add to this, sorry.
In your original question, the direction of the ray was given by origin.transform.forward, not just transform.forward. Are you sure those two objects get rotated to point the desired direction? If you want to get the point you've clicked on, you must use ViewportPointToRay method ( doc )
based on some more research, i think my problem is just something that unity does, thank you for all your help and I am so sorry for any inconvenience caused :)
We have had this happen to us. Legacy projects mostly. Only solution was to start new project. The same model breaks in Unity on one project and works fine in the new one. No idea why.
I personally experienced this. After trying everything from removing repeat on textures to even attempting to hand repair the UVs, it ended up being due to Unity itself. One new project later, a few moments lost rebaking light and resetting up materials, I am back in business. This is an underrated solution and deserves more upvotes. The sad part is this is still an issue 4 years later, and the fix you suggested here still remains viable.
I’ve seen similar issues when people are exporting from 3Ds max and have either open holes in their mesh or have 2 vertices that are in the exact same position. If you are using 3Ds max, then there should be an error when you are exporting saying that the UV coordinates are wrong, you can solve this by selecting all the vertices on your model and use the “weld tool” with the weld radius set to a value very near 0.
If you are not using 3Ds max, then i am not sure what the problem could be, but you could always try messing around with the exporter
public void Shoot() { RaycastHit hit; if (cm.glareOn == true) { if (Input.GetMouseButtonDown(0)) { GameObject bullet = Instantiate(lightbullet, origin.transform.position, Quaternion.identity); if (Physics.Raycast(origin.transform.position, transform.forward, out hit)) { Debug.Log(hit.point); target = hit.point; } } } }
Mostly its because of fbx exporter’s fault. I dont know the reason but I know the solution. Export your object as obj file, then import in max, than re-export as fbx. It should be work. This is the solution.
This worked! Now I wonder why...
– TknoguyficationIn your original question, the direction of the ray was given by
– Helliumorigin.transform.forward, not justtransform.forward. Are you sure those two objects get rotated to point the desired direction? If you want to get the point you've clicked on, you must useViewportPointToRaymethod ( doc )based on some more research, i think my problem is just something that unity does, thank you for all your help and I am so sorry for any inconvenience caused :)
– sarahfoojn