0% found this document useful (0 votes)
37 views

Instantiate (Hiteffect, Hit - Point, Quaternion - Lookrotation (Hit - Normal) )

To rotate an object, transform its localRotation using a quaternion constructed from euler angles. Instantiate takes a position, rotation, and prefab to spawn an object. To make an object a child, set its transform.parent. Coroutines allow waiting using yield return without blocking other code. Lerp smoothly interpolates between values over time. Animator controllers contain states that can be triggered to play animations in response to conditions. Raycasts detect interactions by casting rays and checking for collisions.

Uploaded by

Moeen Arif
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Instantiate (Hiteffect, Hit - Point, Quaternion - Lookrotation (Hit - Normal) )

To rotate an object, transform its localRotation using a quaternion constructed from euler angles. Instantiate takes a position, rotation, and prefab to spawn an object. To make an object a child, set its transform.parent. Coroutines allow waiting using yield return without blocking other code. Lerp smoothly interpolates between values over time. Animator controllers contain states that can be triggered to play animations in response to conditions. Raycasts detect interactions by casting rays and checking for collisions.

Uploaded by

Moeen Arif
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

 ` For rotation:

We do:

o Transform.localRotation = quarternion.euler( x(pitch) , y(yaw) , x (roll) )

 To initialize at runtime we use:

Instantiate( gameobject , vector3 position , quarternion rotation)


Instantiate(hitEffect, hit.point, Quaternion.LookRotation(hit.normal));

Quarternion.identity for no rotation

 To make a child we define its parent like:

Vfx Is a gameObject we want to make its transform a child we define its parent

Vfx.transform.parent = PARENT NAME;

 If I want a function to return and come back or want to wait a few sec before doing the next
thing while not stopping the execution of other things

We use IEnumerator as return type and instead of return we use yield return

Also the function which has this stuff needs a co routine function on call like

: StartCoroutine (function call)

 Move smoothly between points or waypoints

Use Lerp

Vector3.LERP ( startPosition, endPosition , travelPercent)

 Use range for fixed output result also for slider

Which is [Range(minvalue, maxvalue )] it is float

 For particle collding to gameobject use: onparticlecollisonenter() also make sure that the particle
has send collion message ON in collison

///////

For RayCasting shooting games


Use raycast system first detect input from input.getButtondown(“name of button from input manager”)

Then use raycast to form ray

By

Physics.Raycast(destination, direction, outout in raycast hit, range);

//////////////

Animation adding

First need a animation controller then need animater on gameobject then attach the controller in
inspector of that gameObject

Lastlty use controller to add states an change state conditions . the animations goes on states in
animator controller.

To change states based on condition in code we type:

getComponent<Animator>().setTrigger(“name of condition here”); for trigger

animation event: can be added to animation by [long cylendrical icon]

then you can call a function to match the timing with the events.

///////

For looking at something in its script of ai type this:


void FaceTarget()
{
Vector3 direction = target.position - transform.position;
// getting vector which in in between the target and that obj

Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0,


direction.z));
//here I don’t want to change y so new vector but you can do it. We are using
lookRoatation //function which is giving us the direction to look it takes that object
rotation and new //direction vector

transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime *


turnSpeed);
// here using slerp which is making rotation to happen smoothly at turnSpeed
}

///////////////

Broadcast Message(“string reference to function”)

// can call any function with the name in child or gameObject

// able to as many function with same name.


/////////////

You might also like