查看: 2502|回复: 1
打印 上一主题 下一主题

[提问] 怎样让物体跟着手指移动?

[复制链接]

2508

主题

2

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
32806
精华
12

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2013-6-4 10:00:03 |只看该作者 |倒序浏览
在unity for iphone中,为了让物体跟着我的手指移动,要转换坐标,但是进不了最后一个if,不知道问题出在哪,请大家帮我看看。这是我的代码
var buttonForSFX: GUITexture;
if (iPhoneInput.touchCount > 0 && buttonForSFX.HitTest(iPhoneInput.GetTouch(0).position))
{
if (iPhoneInput.GetTouch(0).phase == iPhoneTouchPhase.Moved)
{
if(iPhoneInput.GetTouch(0).position.x <= 338 && iPhoneInput.GetTouch(0).position.x >= 127)
{
var hit: RaycastHit;
var sfxRay: Ray = Camera.main.ScreenPointToRay (iPhoneInput.GetTouch(0).position);
if (Physics.Raycast(sfxRay,hit,1000))
{
print("hit point" + hit.point.x);
buttonForSFX.transform.position.x = hit.point.x;
}
}
}
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

0

主题

1

听众

391

积分

设计实习生

Rank: 2

纳金币
1
精华
0

最佳新人

沙发
发表于 2013-6-4 13:00:49 |只看该作者
没人回答vfbk
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-9-21 18:00 , Processed in 0.081364 second(s), 31 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部