Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Character movement script advice.

    Hello everyone,im new to programming and have been learning a little bit of JavaScript.Im mostly learning it for a program called unity 3d,Its a game engine.And well,im stuck and can't figure this part out.i was wondering if anyone could help me.
    the script is to make the character move forward and shoot.but the character jumps instead of moving forward. any advice?
    Code:
    var speed = 3.0;
    
    var rotateSpeed = 3.0;
    
    var bullitPrefab:Transform;
    
    
    
    function Update () 
    
    {
    
    		var controller : CharacterController = GetComponent(CharacterController);
    
    		
    
    		// Rotate around y - axis
    
    		transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
    
    		
    
    		// Move Forward / backward
    
    		var forward = transform.TransformDirection(Vector3.forward);
    
    		var curSpeed = speed * Input.GetAxis ("Vertical");
    
    		controller.SimpleMove(forward * curSpeed);
    
    		
    
    		if(Input.GetButtonDown("Jump"))
    
    		{
    
    			var bullit = Instantiate(bullitPrefab, GameObject.Find("spawnPoint").transform.position,
    
    Quaternion.identity);
    
    		}	
    
    }
    
    
    
    @script RequireComponent(CharacterController);
    Last edited by blackgoldwolf; 01-27-2012 at 07:31 AM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,928
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose. You can (and should) edit it to make it more meaningful.

    I don't think you have exposed nearly enough code for anyone to solve your problem.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry will fix it right now.and thats the whole code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •