2019年5月28日 星期二

逸臻的筆記Week15-期末作品進度#6(隨機題目)

-期末作品進度#6(隨機題目)-


隨機題目


  1. 加入一個cube板子當題目板
  2. 新增material(題目圖片)
  3. 程式放入cube

程式碼 ( 原版 _ 每秒會換一張 )

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class chagneMatQuck : MonoBehaviour
{
    public Material mat1;
    public Material mat2;
    public Material mat3;
    
    // Start is called before the first frame update
    void Start()
    {
        
    }
    int frameN=0;
    // Update is called once per frame
    void Update()
    {
        if(frameN%60==0){
            int now= (int)(frameN/60)%3;
            Renderer thisRend = GetComponent<Renderer>();
            if(now==0) thisRend.material = mat1;
            if(now==1) thisRend.material = mat2;
            if(now==2) thisRend.material = mat3;
        }        
        frameN++;
    }
}

程式碼 ( 新版 _ 一次換一張 )

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cvb : MonoBehaviour
{
    public Material mat1;
    public Material mat2;
    public Material mat3;
    
    // Start is called before the first frame update
    void Start()
    {
  int now= Random.Range(0,3);
            Renderer thisRend = GetComponent<Renderer>();
            if(now==0) thisRend.material = mat1;
            if(now==1) thisRend.material = mat2;
            if(now==2) thisRend.material = mat3;
        
    }
    //int frameN=0;
    // Update is called once per frame
    void Update()
    {

    }
}




Week15_05160664

Week15
1.今天終於順利的合併地圖檔和程式檔了
2.開始Debug程式碼,今天在小葉老師的協助下,我們會射擊子彈出來了
程式碼如下
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
public class bullet : MonoBehaviour
{
    public SteamVR_Action_Boolean myTrigger;
    public GameObject mybullet;
    public GameObject myController;
    float x = 0;
    bool state = false;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (myTrigger.GetState(SteamVR_Input_Sources.Any))
        {
            if (state == false)
            {
                state = true;

                GameObject now = Instantiate(mybullet);
                now.transform.position = myController.transform.position;
                now.transform.rotation = myController.transform.rotation;
                Rigidbody rb = now.GetComponent<Rigidbody>();
                rb.velocity = new Vector3(0, 0, 100);
                rb.velocity = transform.rotation * rb.velocity;
                Destroy(now, 15f);
            }
        }
        else
        {
            state = false;
        }

    }
}

Week15 +1 notes

一個題目板可以秀圖片,放入三個圖片,圖片一秒會換下一張
  1. 增加cube
  2. 增加material
  3. shader改成specular
  4. 照片拉到material右邊正方形框
  5. 把程式拉給cube
  6. 再把下面做好的material放入程式底下



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class chagneMatQuck : MonoBehaviour
{
    public Material one;
    public Material two;
    public Material three;
    
    // Start is called before the first frame update
    void Start()
    {
        
    }
    int frameN=0;
    // Update is called once per frame
    void Update()
    {
        if(frameN%60==0){
            int now= (int)(frameN/60)%3;
            Renderer thisRend = GetComponent<Renderer>();
            if(now==0) thisRend.material = one;
            if(now==1) thisRend.material = two;
            if(now==2) thisRend.material = three;
        }        
        frameN++;
    }
}

Week15 矮矮的筆記

找到了其他寫法
尋求老師的幫助
發現程式不可以全部寫在一個物件上
要分開寫

1.控制球出現的程式


2.球自己本身的程式(要三個因為有三顆球
這樣寫就可以讓球按照拍子出現

week15 Jie

七巧板製作

1.將事先建好的七巧板模型匯入Unity,並加入Mesh Coilder以利後面做碰撞偵測


2.加入程式碼拿起七巧板


程式碼如下:
    void OnTriggerStay(Collider col) {       
        if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger) && col.tag!="desk"){   
            //Debug.Log ("抓起");       
            // 將 physics(物理引擎) 關掉            
            col.attachedRigidbody.isKinematic = true;         
            // 設定controller為parent            
            col.gameObject.transform.SetParent(gameObject.transform);
        }     
        if (device.GetPressUp (SteamVR_Controller.ButtonMask.Trigger)) {               
            col.gameObject.transform.SetParent (null);           
            col.attachedRigidbody.isKinematic = false;           
            //GameObject.Destroy (col.gameObject, 3f);            
            //tossObject (col.attachedRigidbody);        
        }   
    } 

3.過關條件判斷
單個七巧板放置在木板上時,設定布林值為真。當所有的七巧板都放在木板上,每塊七巧板的布林值皆為真,即達成過關條件

布林值條件程式碼:
    void OnCollisionStay(Collision other) {
        if(other.gameObject.tag=="desk")
            blue=true;
    }

    void OnCollisionExit(Collision other) {
        if(other.gameObject.tag=="desk")
            blue=false;
    }

過關條件程式碼:
    void Update () {       
        device = SteamVR_Controller.Input ((int)trackedObj.index);     
        if(col_blue.blue&&col_gray.gray&&col_green.green&&col_orange.orange&&col_yellow.yellow&&col_purple.purple&&col_red.red&&col_black.black)
        {
            puzzover=true;
            SceneManager.LoadScene ("start_menu");
        }
    }

4.加入移動角色的程式碼,好移動拿取七巧板
(以原先旋轉物體的程式碼做修改)
程式碼:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class tranlate : MonoBehaviour
{
    // Start is called before the first frame update
    SteamVR_TrackedObject trackedObj;
SteamVR_Controller.Device device,deviceLeft,deviceRight;
    public GameObject obj;
    float a=0.0f,b=0.0f,c=0.0f;
    Vector2 rotat=new Vector2(0.0f,0.0f);
    void Start()
    {
        trackedObj=GetComponent<SteamVR_TrackedObject>();
a=obj.transform.position.x;
b=obj.transform.position.y;
c=obj.transform.position.z;
    }

    // Update is called once per frame
    void Update()
    {
        device = SteamVR_Controller.Input ((int)trackedObj.index);
        if (device.GetPress (SteamVR_Controller.ButtonMask.Touchpad)){
rotat = device.GetAxis ();
float angle=Vector2.Angle (new Vector2 (1, 0), rotat);
if (angle > 45 && angle < 135) {
if (rotat.y > 0)
c+=0.02f;
else
c-=0.02f;
}
else {
if (rotat.x>0)
a+=0.02f;
else
a-=0.02f;
}
}
obj.transform.position = (new Vector3 (a, b, c));

week15

*漢堡模型 (MAYA)

起司

小黃瓜

漢堡底層

漢堡上層

生菜



洋蔥

番茄

整顆漢堡


*飲料模型

可樂

雪碧


Week15_ㄩㄐ的快樂雨天

Week 15 目標

① 更新期末作品進度

額外目標:VR Battle

① 更新期末作品進度

▶ 參考老師提供的改變方法
↑ 我們組(13)最需要的是Part 2

▶ 程式參數使用
用於定位物件的方向


生成預置物

找射出正確方向的方法

對沒有錯

明目了然要生成 Instantiate
 
看了好多怎麼覺得還是一知半解

額外目標:VR Battle

 相關連結:

黃惠嘉05160080_VR_Week15

1.期末製作
透過TouchPad移動位置
using System.Collections; using System.Collections.Generic; using UnityEngine; using Valve.VR; public class ViveInput : MonoBehaviour { public GameObject CameraRig; public SteamVR_Action_Boolean triggerDown; public SteamVR_Action_Vibration hapticAction; public SteamVR_Action_Single squeezeAction; public SteamVR_Action_Vector2 touchpadTouch; // Start is called before the first frame update void Start() { } bool bPressed=false; Vector2 oldPos; // Update is called once per frame void Update() { //問題 移動方向不會跟頭的方向一樣(未解決) Vector2 padPos = touchpadTouch.GetAxis(SteamVR_Input_Sources.Any); if(padPos != Vector2.zero){ if(bPressed==false){ oldPos = padPos; bPressed=true; } }else { bPressed=false; oldPos=Vector2.zero; } Vector2 goSpeed2 = padPos-oldPos; Vector3 goSpeed3 = new Vector3(-goSpeed2.x, 0, -goSpeed2.y); Quaternion headDirection = CameraRig.transform.rotation;///SteamVR CameraRig 's rotation of HMD Vector3 realSpeed = headDirection * goSpeed3; CameraRig.transform.position += realSpeed*3; if(triggerDown.GetState(SteamVR_Input_Sources.RightHand)) { hapticAction.Execute(0, 1, 150, 75, SteamVR_Input_Sources.RightHand); print ("triggerDown"); } if(triggerDown.GetState(SteamVR_Input_Sources.LeftHand)) { hapticAction.Execute(0, 1, 150, 75, SteamVR_Input_Sources.LeftHand); print ("triggerDown"); } float triggerValue = squeezeAction.GetAxis(SteamVR_Input_Sources.Any); //Vector2 padPos = touchpadTouch.GetAxis(SteamVR_Input_Sources.Any); if(triggerValue > 0.0f) { print(triggerValue); } } }
2.maya 製作

week15

week 15

- 新增射擊、計分、鴨子物件移動出現程式碼。

鴨子程式碼帶入Unity測試時就壞了,壞掉的原因未知。
處理完這個bug就算完成了

Week15 安淇的筆記

子彈碰觸到敵人的時候會增加分數

在場景中設置記分板

WEEK15

程式研究
障礙物自轉研究

week15

場景切換


1. 設定雷射碰到機器開關(紅色按鈕),切換成糖罐持續轉動之場景



2. 按住Touchpad竹籤可旋轉,放開停止旋轉











絲纏繞

絲可纏繞至長方體上, 之後會把長方體換成竹籤,由於竹籤的大小相較於
長方體而言較小,所以可能絲發射的位置範圍也需要跟著調整





















week15_05090343


1.改善子彈方向問題


VR Real Week15



期末作品持續更新中


海洋場景完成~!!!

Week 15 葉政翰

需要開會討論內容:

  1. VR移動方式:射線移動 / touchpad移動 / 其他方式移動
  2. VR點選UI的方式:射線點選 / 手指觸碰到UI點選
  3. UI的呼叫方式途徑
  4. 劇情
  5. 素材
  6. 合成效果及時間
  7. 臨時動議

Week15

Week15
1.今天順利的合併地圖和程式檔了(感動!!)
哇~有場景跟程式碼了
2.開始程式碼的Debug的環節惹!!
今天在老師的協助下,我們有子彈會飛了~~~
程式碼如下
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
public class bullet : MonoBehaviour
{
    public SteamVR_Action_Boolean myTrigger;
    public GameObject mybullet;
    public GameObject myController;
    float x = 0;
    bool state = false;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (myTrigger.GetState(SteamVR_Input_Sources.Any))
        {
            if (state == false)
            {
                state = true;

                GameObject now = Instantiate(mybullet);
                now.transform.position = myController.transform.position;
                now.transform.rotation = myController.transform.rotation;
                Rigidbody rb = now.GetComponent<Rigidbody>();
                rb.velocity = new Vector3(0, 0, 100);
                rb.velocity = transform.rotation * rb.velocity;
                Destroy(now, 15f);
            }
        }
        else
        {
            state = false;
        }

    }
}