Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SpyderManToo · Feb 08, 2021 at 05:57 PM · positionlerpaimfovaimdownsights

Aiming problem

Im trying to add aiming and Ive encountered a few problems

heres the code so far

 void Aim()
     {
     if(Input.GetMouseButtonDown(1))
     {
         fpsCam.fieldOfView = 55f;
         playerLook.mouseSensitivity = 50f;
         rifle.position = rifleAimPos.position;
 
         Debug.Log("Pistol is moving position");
          pistolHolder.position = pistolAimPos.position;
         Debug.Log("Pistol has moved");
     }
     else if(Input.GetMouseButtonUp(1))
     {
         fpsCam.fieldOfView = 70f;
         playerLook.mouseSensitivity = 100f;
         rifle.position = rifleStore.position;
         pistolHolder.position = pistolHolderStore.position;
     }
     }

when i use this code, the rifle moves when you aim but the pistol never moves, it only changes the fov of the camera.

also, im trying to use lerp to smooth the transition but it wont work. it only moves on the z axis. ive made sure to set the pistol aim position to something else but it still wont move.

can anyone help me?

how do i lerp with positions

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by SpyderManToo · Feb 09, 2021 at 04:52 AM

ok idk how this worked but if i put the pistol instead of the pistolholder in the pistolholder slot, it worked, POG

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by GeroNL · Feb 09, 2021 at 02:56 AM

Make sure the behaviour to change the position is same with rifle. Try to change this :

 pistolHolder.position = pistolAimPos.position;    

to :

 pistolHolder.position = rifleAimPos.position;

if it can, then your set of pistolAimPos.position doesn't work properly, try to look over there


For Lerp do it on set of "pistolAimPos.position", change the it with :

 float SpeedMove = 2.5f;
 position = Vector3.Lerp(position, finalPosition, SpeedMove * Time.deltaTime);

Hope it help.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SpyderManToo · Feb 09, 2021 at 04:48 AM 0
Share

the lerp code doesnt work bc it says cannot convert from unityengine.transform to unityengine.vector3

changing what the positino changes to still doesn't work. ;-;

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

138 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Mathf.Lerp not working 2 Answers

Move object while rotating another one 1 Answer

Orthographic position to Perspective position 0 Answers

Instantiate a projectile facing a Vector3 position in C# 1 Answer

I want to lerp a gun from positionA to positionB in relation to the main camera 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges