Aim Down Sight with multiple scopes.

Updated on June 12, 2017 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
5 on June 11, 2017

Hey, so I want to make an Aim Down Sight script where the gun moves to the center of the camera. Currently, I’m using Vector3.Lerp to lerp between a “normal Vector” and an “aiming Vector” wich I set up via the editor. Now I have the problem that I have many attachments for multiple guns in my game so the “point” wich has to be in the center of the screen changes with each scope attached to the gun and I really don’t want to set up a new vector3 for each variation of guns and scopes. I tried many things like calculating the distance between the screen center and the middle of the scope and then creating a new vector3 off this distance via script but nothing worked as expected. Do you guys have any ideas or suggestions how to get this working?

 

I’m really thankfully for every reply! 

  • Liked by
Reply
4 on June 11, 2017

maybe create a reference point on each scope where the script will look for?

on June 11, 2017

Did that already but then the reference point is a child of the gun and then it only lerps the reference point not the gun it self :/

Wise
on June 11, 2017

Make the reference point a child of the scope?

 

on June 11, 2017

That’s exactly what I did. I guess you would need to lerp this reference point then to get it working as expected. But I think you missed that the reference point is just a CHILD of the scope and the scope is a child of the gun. So if I lerp the reference point I only lerp that transform NOT the gun it self.

Wise
on June 12, 2017

Then you’ll have to do some tweening yourself without the lerp. Change the guns position until the reference point is where you want it to be.

 

Show more replies
  • Liked by
Reply
Cancel