Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-27-2012, 06:58 AM   PM User | #1
blackgoldwolf
New to the CF scene

 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
blackgoldwolf is an unknown quantity at this point
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..
blackgoldwolf is offline   Reply With Quote
Old 01-27-2012, 07:24 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
Philip M is offline   Reply With Quote
Old 01-27-2012, 07:28 AM   PM User | #3
blackgoldwolf
New to the CF scene

 
Join Date: Jan 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
blackgoldwolf is an unknown quantity at this point
sorry will fix it right now.and thats the whole code.
blackgoldwolf is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:40 PM.


Advertisement
Log in to turn off these ads.