Page 1 of 1
					
				!!! Click and Move !!!
				Posted: Wed Aug 18, 2010 11:26 pm
				by Asgarth
				Hey guy's.
I have yesterday downloaded untiy3d 

 and uhm it's amazing, but well TOTAL NOOB HERE.
I know i should look at all tut's for this, but yeah tiering to look at all 
 
Anyways i have a basic question first of all.
How do i make a click and move script 
 
I mean, when i click on the ground i move my char there 
 
Sincere:
Asgarth aka Michael B
 
			
					
				Re: !!! Click and Move !!!
				Posted: Thu Aug 19, 2010 12:01 am
				by SpiritWebb
				I been working with Unity for a while now, and I myself have not figured out how to do it.  I would like to know this too...
			 
			
					
				Re: !!! Click and Move !!!
				Posted: Thu Aug 19, 2010 12:23 am
				by Sakar
				I will mess with this idea. Give me an hour or two and I should have something for you guys 
 
EDIT: Here's a UnityPackage I put together. It contains the script and an example scene showing it at work. To import a package click Assets > Import Package
http://dl.dropbox.com/u/837167/ClickToMove.unitypackage 
			
					
				Re: !!! Click and Move !!!
				Posted: Thu Aug 19, 2010 3:27 am
				by SpiritWebb
				Thanks!  I will take a look at this as soon as I get home and try it out and let you know!  A big help...been trying to search on how to do this for months...
			 
			
					
				Re: !!! Click and Move !!!
				Posted: Thu Aug 19, 2010 6:10 am
				by SpiritWebb
				It works...great job.
The only problem I am having, is it doesn't register that the ground/plane has changed height.  It stays moving on a flat surface, and will go through mountains, etc.  The other problem I just tested seems that when you click it, and the smooth is set to 1, it travels almost instantly to that location, not a smooth walk like when using the WASD or arrow keys.  Otherwise it works wonderfully.
Any idea on how to correct this?
			 
			
					
				Re: !!! Click and Move !!!
				Posted: Thu Aug 19, 2010 8:12 am
				by Asgarth
				Sakar wrote:I will mess with this idea. Give me an hour or two and I should have something for you guys 
 
EDIT: Here's a UnityPackage I put together. It contains the script and an example scene showing it at work. To import a package click Assets > Import Package
http://dl.dropbox.com/u/837167/ClickToMove.unitypackage 
Many Thanx.
 
			
					
				Re: !!! Click and Move !!!
				Posted: Thu Aug 19, 2010 5:12 pm
				by Sakar
				SpiritWebb wrote:It works...great job.
The only problem I am having, is it doesn't register that the ground/plane has changed height.  It stays moving on a flat surface, and will go through mountains, etc.  The other problem I just tested seems that when you click it, and the smooth is set to 1, it travels almost instantly to that location, not a smooth walk like when using the WASD or arrow keys.  Otherwise it works wonderfully.
Any idea on how to correct this?
The reason it moves on a flat surface is because it casts a ray to an invisible plane at the same height as the player. This could be fixed by having it cast a ray to the world geometry instead.
The moving issue is because I simply Lerp from one position to another. Instead you'd want to move the player on it's Forward vector until it has reached the desired position. You'd also have to check if the player moved past that position, as it is highly unlikely that it will be exact.
I will see if I can come up with any solutions.
 
			
					
				Re: !!! Click and Move !!!
				Posted: Mon Aug 30, 2010 11:38 pm
				by SweetRevenge
				is there any way to adjust the speed?
			 
			
					
				Re: !!! Click and Move !!!
				Posted: Mon Aug 30, 2010 11:50 pm
				by Sakar
				Change the smooth parameter in the editor.