如何使用两个Vector3点统一创建一条线? [英] How to create a line using two Vector3 points in unity?

查看:80
本文介绍了如何使用两个Vector3点统一创建一条线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一些功能,例如lineRenderer等,但是我想使用两个点(以Vector3形式)在场景中创建一条直线.我不想使用任何键或鼠标来绘制线条,我只想在触发某些事件时或单击播放按钮后立即在场景中看到线条.

I know there exist some functions like lineRenderer etc, but I want to create a straight line in the scene using two points(in Vector3 form). I don't want to draw the line by using any key or using the mouse, I just want to see the line in the scene when I trigger some event or just after I click play button.

有人可以帮助我吗?

推荐答案

好的,我已经通过使用LineRenderer来解决了这个问题:

Ok, I've figured it out by using LineRenderer like this:

var line: GameObject=GameObject.Find("/LineRenderer");
fence = Instantiate(line,Pos,Rotation);
fence.setPosition(0,p1);
fence.setPosition(1,p2);

感谢您上面的所有回答

这篇关于如何使用两个Vector3点统一创建一条线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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