物体的运动 [英] movement of objects

查看:138
本文介绍了物体的运动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我是团结的新人,还在学习我想问一下如何更新对象的另一个对象的移动并使它们一起移动的代码?

解决方案

这些可能会有所帮助 -

Transform.Translate [ ^ ]

视频 - 如何移动游戏对象 [ ^ ]

http://answers.unity3d.com/questions/14279/make-an-object-move-从点到点-b-then-b.html [ ^ ]


将此脚本附加到object1。



 使用 UnityEngine; 
使用 System.Collections;


public class 关注:MonoBehaviour {
GameObject TargetObject;

void Start(){
TargetObject = GameObject.Find( object2);
}

void FixedUpdate(){
this .transform.position = TargetObject.position;
}
}





它在object1上给出与object2完全相同的位置。如果你这不好希望顺利关注。


well , i'm new in unity and still learning i want to ask about code of how to update object the movement of another object and make them move together ??

解决方案

These may help -
Transform.Translate[^]
Video - How to move a gameObject[^]
http://answers.unity3d.com/questions/14279/make-an-object-move-from-point-a-to-point-b-then-b.html[^]


Attach this script to object1.

using UnityEngine;
using System.Collections;


public class Follow: MonoBehaviour {
    GameObject TargetObject;

	void Start () {
        TargetObject = GameObject.Find("object2");
        }
	
	void FixedUpdate () {
        this.transform.position = TargetObject.position;
        }
}



this gives the exact same position on object1 as object2.This is no good if you want a smooth follow.


这篇关于物体的运动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆