Unity 3D Floating Object float up and down

Advertisemen

Unity 3D Floating Object float up and down












DIRECT DOWNLOAD HERE






THIS IS Java# script: GOOD 4 2D GAMES AND 3D GAMES !
----------------------------------------­­­­­­­----------------------------------­-­-­-­-­-­-­------
THIS IS BACKUP  IN TEXT FORM

1. Create New java and name it :  Floating Object


2. Copy & Past this text and save java :



----------------------------------------­­­­­­­----------------------------------­-­-­-­-­-­-­------


#pragma strict

 var floatup;
 function Start(){
     floatup = false;
 }
 function Update(){
     if(floatup)
         floatingup();
     else if(!floatup)
         floatingdown();
 }
 function floatingup(){
     transform.position.y += 0.4 * Time.deltaTime;
     yield WaitForSeconds(1);
     floatup = false;
 }
 function floatingdown(){
     transform.position.y -= 0.4 * Time.deltaTime;;
     yield WaitForSeconds(1);
     floatup = true;
 }



----------------------------------------­­­­­­­----------------------------------­-­-­-­-­-­-­------














BONUS Solution 2
EXTRA OPTION --- Floating Object MoveUpAndDown Solution 2 ..


THIS IS Java# script: GOOD 4 2D GAMES AND 3D GAMES !
----------------------------------------­­­­­­­----------------------------------­-­-­-­-­-­-­------
THIS IS BACKUP  IN TEXT FORM

1. Create New java and name it :  MoveUpAndDown



2. Copy & Past this text and save java :


----------------------------------------­­­­­­­----------------------------------­-­-­-­-­-­-­------



#pragma strict
var amount : float = 1.0;
var speed : float = 4.0;
    function Start () {
var pointA = transform.position;
var pointB = transform.position + Vector3(0, amount, 0);
while (true) {
yield MoveObject(transform, pointA, pointB, speed);
yield MoveObject(transform, pointB, pointA, speed);
}
    }
   
    function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float) {
var i = 0.0;
var rate = 1.0/time;
while (i < 1.0) {
i += Time.deltaTime * rate;
thisTransform.position = Vector3.Lerp(startPos, endPos, i);
yield;
}
    }


----------------------------------------­­­­­­­----------------------------------­-­-­-­-­-­-­------
















Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D