Problem about function "look at "
When I use "look at" the computer can't decides the right direction. For example, I want my gun look at a target, but computer can't set the right direction because it doesn't undersand me I want my gun point the target instead of bottom of gun point it.How can I fix this ?
Answer by Dorscherl · Mar 05, 2018 at 04:43 AM
@pp30 "The computer can't decide the right direction." It's more likely when the modeler was creating it, they didn't point the gun in the direction of the appropriate axis (z-axis i imagine). A quick fix would be to parent your gun in another transform and locally rotate the gun to line up to match the parent's forward direction. Then instead of using gunTransform.LookAt(target) you use gunParentTransform.LookAt(target); A harder fix would be to open a 3D modelling software and open the gun model in it and rotate it in there accordingly. I suggest the first option.