Game Development Lab

 Exp 5. Write a c# script to Destroy game objects Over Time (Object pooling).

 Aim: Write a script to destroy a GameObject within a specific Time.

 using System.Collections;

 using System.Collections.Generic;

 using UnityEngine;

 public class DestroyOverTime : MonoBehaviour

 {

 public float lifeTime;

 // Start is called before the first frame update

 void Start()

 {

 }

 // Update is called once per frame

 void Update()

 {

 /* lifeTime -= Time.deltaTime;

 if(lifeTime< 0)

 {

 Destroy(gameObject);

 } */

 Destroy(gameObject, lifeTime);

 }

 }

  Exp4. Write a C# script for damaging and killing the player depending on his health.

 using System.Collections;

 using System.Collections.Generic;

 using UnityEngine;

 public class KillPlayer : MonoBehaviour

 {

 private void OnTriggerEnter2D(Collider2D other)

 {

 if(other.tag == "Player")

 {

 LevelManager.instance.RespawnPlayer();

 }

 }

 }

Exp.6. Write a c# script for smooth camera follow mechanism.

 Aim: Create smooth camera transition with follow target functionality.

 using System.Collections;

 using System.Collections.Generic;

 using UnityEngine;

 public class CameraFollow : MonoBehaviour

 {

 public Transform target;

 // Start is called before the first frame update

 void Start()

 {

 }

 // Update is called once per frame

 void Update()

 {

 transform.position = newVector3(target.position.x, target.position.y,

 transform.position.z);

 }

 }

 Output

 

Comments

Popular posts from this blog

8) User Authentication: Assume four users user1, user2, user3 and user4 having the passwords pwd1, pwd2, pwd3 and pwd4 respectively. Write a PHP for doing the following. 1. Create a Cookie and add these four user id’s and passwords to this Cookie. 2. Read the user id and passwords entered in the Login form and authenticate with the values (user id and passwords) available in the cookies. If he is a valid user (i.e., user-name and password match) you should welcome him by name (user-name) else you should display ―You are not an authenticated user ’’. Use init-parameters to do this

4. Write a C program to implement the Brute force technique of Top down Parsing.

Web development Lab