10 Replies - 1788 Views - Last Post: 24 November 2011 - 01:36 PM Rate Topic: -----

#1 thaithao  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 22
  • Joined: 29-April 10

Java Game Character movement script

Posted 23 November 2011 - 09:39 PM

Well i would like to say that my movement script works well but not well enough! You see.. i can get it to move but not follow my movement.. for example : i move forward then i look to the left and keep moving (the movement will keep moving to the direction it was moving before). But i dont want that to happen... i want it to follow my directional camera movement! here is the code
		public var MoveSpeed :float = 50;
		
					public var jumpSpeed : float = 55;
					
							public var MoveDirection = Vector3.zero;
							
										public var Gravity :float = 45;
										
												public var grounded : boolean = false;
												
												

  function Start (){

}


function Update () {



		if( grounded ){
		
               MoveDirection = new Vector3(Input.GetAxis("Horizontal"), 0 , Input.GetAxis("Vertical"));
               
               				MoveDirection = transform.TransformDirection(MoveDirection);
               				
               							MoveDirection *= MoveSpeed ;
 
                          

    
                          
}

			if( grounded ) {
			
			if(Input.GetKey(KeyCode.Space)){
			
			
					MoveDirection.y = jumpSpeed;
			
			
			}
	
}


			MoveDirection.y -= Gravity * Time.deltaTime;
			
						var Controller = GetComponent(CharacterController);
						
							var Flags = Controller.Move( MoveDirection * Time.deltaTime);
							
									grounded = (Flags & CollisionFlags.CollidedBelow) !=0;
									
								
}




if possible you can also contact me via ********* and teamview me for a better look. I am using Unity Pro but i went to go ask on their forum and they were of no help.

*Edited: email address removed according to this site policies
And by the way you are in the Java forum, nothing to do with your code
Not sure in which language it is written to move it to the good forum :)

This post has been edited by pbl: 23 November 2011 - 09:42 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Java Game Character movement script

#2 thaithao  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 22
  • Joined: 29-April 10

Re: Java Game Character movement script

Posted 23 November 2011 - 09:48 PM

this is of either java or python.. i forgot since i wrote it a long time ago! and have been studying c-sharp i just got back to it now because i want to use it for my portfolio.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Java Game Character movement script

Posted 23 November 2011 - 09:54 PM

If YOU don't even know what it is.... it is kind of scary :)
But really scary... how do you compile/run it
I know nothing about Python but will move it into the Python forum as this is surely not Java

Note to Python folks: sorry it seems that this might be Python code, but even the OP does not know. Thanks.
Was This Post Helpful? 0
  • +
  • -

#4 thaithao  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 22
  • Joined: 29-April 10

Re: Java Game Character movement script

Posted 23 November 2011 - 10:13 PM

View Postpbl, on 23 November 2011 - 09:54 PM, said:

If YOU don't even know what it is.... it is kind of scary :)
But really scary... how do you compile/run it
I know nothing about Python but will move it into the Python forum as this is surely not Java

Note to Python folks: sorry it seems that this might be Python code, but even the OP does not know. Thanks.


yea it's scary but this is for a game.. it was written inside unity 3d pro
Was This Post Helpful? 0
  • +
  • -

#5 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Java Game Character movement script

Posted 24 November 2011 - 12:30 AM

That's certainly not Python code, so it's not Java or Python. You can write Javascript, C# or a dialect of Python in Unity 3d . It's amazing, and scary as you say, that the OP doesn't know what language this is, I mean how?

I'd hazard a guess that this belongs in the C# forum.
Was This Post Helpful? 0
  • +
  • -

#6 thaithao  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 22
  • Joined: 29-April 10

Re: Java Game Character movement script

Posted 24 November 2011 - 01:20 AM

View PostSimown, on 24 November 2011 - 12:30 AM, said:

That's certainly not Python code, so it's not Java or Python. You can write Javascript, C# or a dialect of Python in Unity 3d . It's amazing, and scary as you say, that the OP doesn't know what language this is, I mean how?

I'd hazard a guess that this belongs in the C# forum.


i hope this picture help a bit
Posted Image

View Postthaithao, on 24 November 2011 - 01:19 AM, said:

View PostSimown, on 24 November 2011 - 12:30 AM, said:

That's certainly not Python code, so it's not Java or Python. You can write Javascript, C# or a dialect of Python in Unity 3d . It's amazing, and scary as you say, that the OP doesn't know what language this is, I mean how?

I'd hazard a guess that this belongs in the C# forum.


i hope this picture help a bit
Posted Image

Was This Post Helpful? 0
  • +
  • -

#7 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Java Game Character movement script

Posted 24 November 2011 - 01:57 AM

Does the filename "FPSInputCon.js" give you a clue? It's Javascript code!
Was This Post Helpful? 0
  • +
  • -

#8 thaithao  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 22
  • Joined: 29-April 10

Re: Java Game Character movement script

Posted 24 November 2011 - 03:32 AM

View PostSimown, on 24 November 2011 - 01:57 AM, said:

Does the filename "FPSInputCon.js" give you a clue? It's Javascript code!


my bad have not opened this project for a long time.. been a year ago.. and i just got back to it! so ^^ sorry! i hope you can still help though
Was This Post Helpful? 0
  • +
  • -

#9 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Java Game Character movement script

Posted 24 November 2011 - 08:27 AM

Python questions only here! You'd be better off posting your question in the Javascript Forum :)
Was This Post Helpful? 0
  • +
  • -

#10 thaithao  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 22
  • Joined: 29-April 10

Re: Java Game Character movement script

Posted 24 November 2011 - 12:04 PM

Mod please move this to javascript please ^^
Was This Post Helpful? 0
  • +
  • -

#11 Ntwiles  Icon User is offline

  • D.I.C Addict

Reputation: 119
  • View blog
  • Posts: 716
  • Joined: 26-May 10

Re: Java Game Character movement script

Posted 24 November 2011 - 01:36 PM

Hahahahahahahahahahaha.

I'm sorry I know that post was helpful in know way. But hahahahahahahahahahahahaha.

This post has been edited by Ntwiles: 24 November 2011 - 01:37 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1