English 中文(简体)
团结3D 结 论
原标题:Unity 3D Spinning a gameobject

我正试图把3D博爱团结在一起。 这实际上是一种yl子,只带有掩体芯片。 一旦与一枚射线相勾结,我就希望把它推向360度。 但是,在团结的支持者中,它只是罚款的,但是在装置本身上,chi子在pin后停下来,然后继续在无休止的 lo中.。 这里是有关法典的幻灯。 感谢你事先提供任何帮助。

    // Spin the chip
if (Animate) {
    if (Speed > 0 && Chip.tag.Contains("Chip")) {
        Chip.transform.Rotate(0, Speed*Time.deltaTime, 0);
        Speed -= 3;
        Debug.Log(Speed);
    }
    else {
        // Reset
        Animate = false;
        Speed = 360;
        Chip.transform.localRotation = Quaternion.Euler(0.0,0.0,0.0);
    }   
}

如果我把手工艺品混为一谈,那么我最能做的事情就是把bject子 assigned成像。

// Set the chip
    Chip = hit.transform;

更新职能中做了一切工作。 射线一旦打上了它称为tt功能,然后在推测之后,它就改变了Boolean Animate,使之真正导致芯片的堆积。

问题回答

其他一些法典中正在设置<代码>Animate = 真实,难以在未见到其余部分的情况下说明这些内容。

在确定Animate的每一个地点旁有一些 de,因此,你应当看到其他的 setting,只是可能解释为什么它继续pin。

另一种选择是使用消化工具,而不是轮换,而你只是玩.,为你们轮换。

Edit:Chances是围绕触角代码进行的,原因是你在编辑上用主要线击.。 我曾经历过几次。

詹姆斯·格拉姆西利是正确的,因为其他一些法典正在再次引发悲观,很可能是你的触动代码。 在编辑与感触装置之间移动时,这是一个共同的问题。 你们可以通过利用团结行动来核实你的法典的管制流动,确定情况是否如此。

尽管如此,我会把你的法典修改到以下,即从每个框架的更新文件中删除了关键代码。 这是一种小的优化,但主要是它清理了建筑,使之更具模块化和小 ne。

你们的法典并不明确,但我将假设你正在使用团结的文字。

在你点击芯片时处理触动代码的文字中,插入以下文字:

hit.transform.SendMessage("Spin", hit.transform, SendMessageOptions.DontRequireReceiver);

将这部法典用一个称为“SpinChip”的单独文字,然后将文字添加到你的芯片上。

var StartSpeed = 360.0;
var Deceleration = 3.0;

function Spin()
{
    if (Animating)
    {
        print("Chip is already spinning, not starting another animation");
        return;
    }

/*
    This code isn t necessary if this exists in a separate script and is only ever attached to the clickable chip
    if (!gameObject.tag.Contains("Chip"))
    {
        print("That wasn t a chip you clicked");
        return;
    }
*/

    print("Chip has been told to spin");
    StartCoroutine(SpinningAnimation);
}

function SpinningAnimation()
{
    print("Chip spin start");
    transform.localRotation = Quaternion.identity;
    Speed = StartSpeed;
    Animating = true;
    while (Speed > 0)
    {
        transform.Rotate(0, Speed*Time.deltaTime, 0);
        Speed -= Deceleration;
        yield; // wait one frame
    }

    print("Chip has completed the spin");
    Animating = false;
}

该守则确实建立了一条共同路线,一旦启动,每条新路程一度运行,就会把chi子带给你,并且独立于你的实际纽扣代码。

var rotSpeed: float = 60; // degrees per second

function Update(){
  transform.Rotate(0, rotSpeed * Time.deltaTime, 0, Space.World);
}

Here is a code that rotates your game object, you can use it just with a vector 3 :transform.Rotate(x, y, z); or with Space transform.Rotate(x, y, z, Space.World); rotSpeed is the rotation speed.

在您的更新职能中。 Bool变量Animate可能变得真实。 这可能是您的圆柱继续轮换的原因。

其他解决办法是: 您可以给您的inder子带来一.,然后进行 stop。 因此,在一段时间后,你可以停止使用停止监视时间的 an。





相关问题
images sliding continuously with <table> and jQuery

I m trying to write a little test page that circulates images through a window (see image). I have colored boxes inside a table (gray border), with each box being a element. <table id="boxes" ...

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

Disable Windows 7 touch animation in WPF

In Windows 7 when you touch the screen there is a short animation that occurs at the touch point. In my WPF app I want to display my own touch points, without showing the one supplied by Windows. ...

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Direct 2D gnuplot PNG animation?

Can anyone please confirm that yes/no Gnuplot 4.5 (on CVS) can output 2D animated PNG files? I have numerous datasets but one line that I d like to show iteratively in 3 different places in my graph. ...

Visual State Manager VS Animations in WPF

There is a lot of talk about the simplicity of Visual States and the transitions between them in WPF/Silverlight. I have the need to generate animations dynamically at runtime, to animate the ...

Create a ImageIcon that is the mirror of another one

I ll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with ...

how to drag in the animation in iphone application?

Iphone application is using the static co-ordinates to reach at some points in the application,which is based on the button event. But what i want is when i drag the item than it should reach at some ...

热门标签