Unity develops Pico handle vibration tutorial

foreword

Hello everyone, I am Chengzi. Recently, due to project requirements, I have been involved in the vibration of the handle, but I have searched for a long time and have not talked about it, so today I will tell you about it.

Detailed API

SetControllerVibration

函数名:public static void SetControllerVibration(float strength, int time, Controller controller)

Explanation of technical terms

Function: make the handle vibrate

parameter:

  • Vibration intensity (strength): 0 - 1
  • Duration unit milliseconds (time): 0 - 65535
  • controller: left and right handles

Call method: PXR_Input.SetControllerVibration (strength, time, controller)

technical details

using static Unity.XR.PXR.PXR_Input;
using Unity.XR.PXR;
using UnityEngine;

public class ElectrocotyController : MonoBehaviour
{
    
    
	public Controller controller_L; // 左手柄或右手柄
    public Controller controller_R; // 左手柄或右手柄


	void Start()
	{
    
    
		//震动强度:0.1f、时间2000毫秒(2秒)、震动左手柄还是右手柄(这里是两个都震动)
		PXR_Input.SetControllerVibration(0.1f, 2000, controller_L);
        PXR_Input.SetControllerVibration(0.1f, 2000, controller_R);
	}
}

insert image description here
After copying, you need to adjust your handle in Unity for mounting, otherwise the default is the left handle, and the right handle does not vibrate

Summarize

It is a very simple explanation of Pico API vibration. When you are developing, you must read more documents!
Document address: https://sdk.picovr.com/docs/XRPlatformSDK/Unity/cn/chapter_seven.html

If it helps you, please like and collect! Thanks

Guess you like

Origin blog.csdn.net/weixin_45375968/article/details/131780150