1
0
forked from cgvr/DeltaVR

printer spawns object in correct place, size, and plays sound

This commit is contained in:
2026-02-15 12:38:13 +02:00
parent 46400bc1f0
commit bd8a3d90ca
6 changed files with 522 additions and 12 deletions

View File

@@ -1,7 +1,5 @@
using FMOD.Studio;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Printer3D : MonoBehaviour
@@ -9,6 +7,7 @@ public class Printer3D : MonoBehaviour
public Transform spawnPoint;
public int ignorePlayerCollisionLayer = 2;
public string shapeScannerTag = "ShapeScannable";
public float printedObjectSize = 0.5f;
private bool isPrinting = false;
private EventInstance printingSound;
@@ -19,6 +18,8 @@ public class Printer3D : MonoBehaviour
{
printingSound = AudioManager.Instance.CreateInstance(FMODEvents.Instance.Printing);
printingSound.setParameterByName("3DPrinterPrintingJob", 1);
printingSound.setParameterByName("Occlusion", 0);
printingSound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(spawnPoint));
}
// Update is called once per frame
@@ -36,7 +37,7 @@ public class Printer3D : MonoBehaviour
string encodedTexture = Convert.ToBase64String(texture.EncodeToJPG());
byte[] encodedModel = await TrellisClient.Instance.GenerateModel(encodedTexture);
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel);
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel, printedObjectSize);
InitializeSpawnedObject(spawnedObject);
if (GeneratedModel != null)
{

View File

@@ -62,9 +62,7 @@ public class Printer3DInputHole : MonoBehaviour
// 2) Make sure physics doesn't fight the tween (optional but recommended)
if (rb != null)
{
rb.isKinematic = true; // prevent forces during tween
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
rb.isKinematic = true;
}
// 3) Optionally disable grabbing during the tween so the player can't re-grab mid-flight