your coworkers to find and share information.
Stack Overflow for Teams is a private, secure spot for you and Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers. Free 30 Day Trial

I have implemented a click 2 move script and i'm trying to use a method that already gets a Vector3 of where I clicked and moves the player via CharacterController to it.is there a way to take the transforms current position, get the values from GetAxis while the keys are down and calculate its new position.


of math, addition. And thank you for taking the time to help us improve the quality of Unity Documentation. Returns the value of the virtual axis identified by axisName with no smoothing filtering applied. If the axis is mapped to the mouse, the value is different and will not be in the range of -1...1. Please try again in a few minutes. Stack Overflow works best with JavaScript enabled Transform.forward moves the GameObject in the blue arrow’s axis (Z). Thank you for helping us improve the quality of Unity Documentation. Where developers & technologists share private knowledge with coworkersProgramming & related technical career opportunitiesDo I understand you want to click, click again, and move from the first click pos to the second?Do you mean you want the player to keep moving towards the mouse while the left mouse button is down? and add the velocity.so position+(Vector3.forward) in a update function would make it increase Vector3(0,0,n) with each frame.In short that is what the code would have to do, if we use Vector3.forward, but you will most likely use your own variables such as if that is called after the move has been performed that frame, you will get the position on the forward axix ( you'll also have to add from side to side and up and down i guess ) but its the position of the player next frame, so you can check if a wall is there and if so dont allow player to move forward next frame, which is old school collision detection. - Beginner Scripting Tutorial - YouTube By using our site, you acknowledge that you have read and understand our when the vertical/horizontal controls are release the Vector3 would be assigned the transforms current position so it will stop movingposition is assigned from a raycast so I would like to use the players current position, what ever the calculations are required with getaxis and adjust accordingly Sure, back when games where done without a engine that was the simplest way to calculate collision detection,but you will have to take in to account a lot of variables and how they change. Close. The Overflow Blog Cancel. Thanks for contributing an answer to Stack Overflow! basically if you wanna know where the player is going to be you have to use the simplest site design / logo © 2020 Stack Exchange Inc; user contributions licensed under Typically a positive value means the mouse is moving right/down and a negative value means the mouse is moving left/up. How to "get axis" based input for your games in Unity and how these axes can be modified with the Input manager This tutorial is included in the Beginner Scripting … By clicking “Post Your Answer”, you agree to our To subscribe to this RSS feed, copy and paste this URL into your RSS reader. When a GameObject is rotated, the blue arrow representing the Z axis of the GameObject also changes direction. And thank you for taking the time to help us improve the quality of Unity Documentation.Returns the value of the virtual axis identified by The value will be in the range -1...1 for keyboard and joystick input devices.

Unity is the ultimate game development platform. Your name Your email Suggestion * Submit suggestion. For moving the GameObject on the Z axis while ignoring rotation, see Vector3.forward . Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.For some reason your suggested change could not be submitted. if that is called after the move has been performed that frame, you will get the position on the forward axix ( you'll also have to add from side to side and up and down i guess ) but its the position of the player next frame, so you can check if a wall is there and if so dont allow player to move forward next frame, which is old school collision detection. C# GetAxis in Unity! Instead it'll be the current mouse delta multiplied by the axis sensitivity. Featured on Meta public static float GetAxisRaw (string axisName); Description.