(Unity Beginner) Frogger type 2d Game JavaScript Help

Hello, and thanks for your help in advance. I’m starting to design a game for school to design a frogger type overhead 2d game using JavaScript in Unity. My main question would be how would I make my object(Frog in this case) hop Forward, backwards, left, and right? I think after I can get this script working everything else wouldn’t be so tough. I just need an basic idea and maybe some code to get me started on my game. Thank you

while this is untested, it will give you an idea of how it works. here is the doc on it

var frog : Transform;


function Update() {
	// we run input GetKeyDown in Update function as the true value will be reset after each frame
	// Update is run per each frame
	// when player presses up key move the frog forward one unit 
	// you can increase the units moved by doing this:
		// Vector3.forward * 1.5f
	if(Input.GetKeyDown("up")) {
		frog.position = Vector3.forward;
	}
	
	if(Input.GetKeyDown("down")) {
		frog.position = Vector3.back;
	}
	
	if(Input.GetKeyDown("left")) {
		frog.position = Vector3.left;
	}
	
	if(Input.GetKeyDown("right")) {
		frog.position = Vector3.right;
	}
}

Thank you =D gonna try this out, thanks for your quick response !!!

So for example. If i wanted to change the units moved it would look exactly like this ? Vector3.forward * 1.5f ? with the * ??

exactly

Vector3.forward will move the GameObject in the z axis one unit.

Vector3.forward * 1.5f is multiplying 1 unit by 1.5 units. The ’ * ’ means multiply in programming

doc reference for it

Gottcha, Thanks a million!!

UnassignedReferenceException: The variable frog of ‘frog jumping’ has not been assigned.
You probably need to assign the frog variable of the frog jumping script in the inspector.
UnityEngine.Transform.set_position (Vector3 value) (at C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/ExportGenerated/Editor/UnityEngineTransform.cs:27)
frog jumping.Update () (at Assets/frog jumping.js:11)

is the error im getting while trying to run this script … i know its basic but like i said im just starting to learn unity … thanks