This might be a tricky one.
-I’ve got a character with a gun
-When I hit V I can switch between first and a 3rd person/over the shoulder view.
-I’ve got the crosshair and camera moving fine
-I’ve got an empty object at the tip of the gun where bullets are instantiated from.
My problem is, I can’t figure out a good way to keep this empty object pointed at the center of the screen, ie keep the bullets traveling to where the crosshair is aiming.
I tried putting a smoothLookAt script on the empty, and jack the damping up, and make the crosshair the target, but that only works if the enemy happens to be the exact distance from the gun as the crosshair.
I tried putting a smoothLookAt script on the gun, and parenting the empty to the gun. This sort of worked, the bullets would travel to the center of the screen, but they’d only reach the center of the screen at a vast distance. Shooting wide at a short or even normal range.
Does anyone have any suggestions? I have it setup in such a way I can try anything pretty quickly, so suggest anything you can think of please. :]
[EDIT]I’m thinking now maybe what I need to do is fire a Ray from the centre of the camera, and point the empty object at the hit point. But I have no idea how on earth I’d accomplish this. Anyone got any ideas?[EDIT]