CGP Assignment #02
CGP Assignment #02
2:
SCRIPT:
SCRIPT:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
}
// Update is called once per frame
void Update()
if(Input.GetKey(KeyCode.UpArrow))
OUTPUT:
2. Down Arrow – Movement downword direction:
SCRIPT:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
void Update()
if(Input.GetKey(KeyCode.DownArrow))
}
}
Output:
3. Left Arrow – Movement left direction (face of the character should be in left
side):
SCRIPT:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
void Update()
{
if(Input.GetKey(KeyCode.LeftArrow))
transform.localScale=new Vector2(-3,3);
OUTPUT:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
void Update()
if(Input.GetKey(KeyCode.RightArrow))
transform.localScale=new Vector2(6,6);
transform.Translate(Vector2.right *Time.deltaTime *2.5f);
OUTPUT:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
void Update()
{
if(Input.GetKey("a"))
transform.localScale=new Vector2(transform.localScale.x*2,transform.localScale.y*2);
OUTPUT:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
{
}
void Update()
if(Input.GetKey("s"))
transform.localScale=new Vector2(transform.localScale.x/2,transform.localScale.y/2);
}
}
OUTPUT:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Move : MonoBehaviour
void Start()
void Update()
{
if(Input.GetKey("h"))
transform.position=new Vector2(0,0);
OUTPUT: