gpt4 book ai didi

unity-game-engine - 创建游戏对象的副本

转载 作者:行者123 更新时间:2023-12-02 17:54:41 25 4
gpt4 key购买 nike

如何在 Unity3D 中单击鼠标创建对象的副本?

另外,如何在运行时选择要克隆的对象? (最好选择鼠标)。

最佳答案

function Update () {

var hit : RaycastHit = new RaycastHit();
var cameraRay : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);

if (Physics.Raycast (cameraRay.origin,cameraRay.direction,hit, 1000)) {
var cursorOn = true;
}

var mouseReleased : boolean = false;

//BOMB DROPPING
if (Input.GetMouseButtonDown(0)) {

drop = Instantiate(bomb, transform.position, Quaternion.identity);
drop.transform.position = hit.point;

Resize();

}
}

function Resize() {
if (!Input.GetMouseButtonUp(0)) {
drop.transform.localScale += Vector3(Time.deltaTime, Time.deltaTime,
Time.deltaTime);
timeD +=Time.deltaTime;
}
}

您会希望在多次调用 Update 的过程中发生这种情况:

function Update () {
if(Input.GetMouseButton(0)) {
// This means the left mouse button is currently down,
// so we'll augment the scale
drop.transform.localScale += Vector3(Time.deltaTime, Time.deltaTime,
Time.deltaTime);
}
}

关于unity-game-engine - 创建游戏对象的副本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3526941/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com