坠落时玩家重生和死亡

时间:2016-11-14 19:00:32

标签: c# unity3d 3d

我现在正在经历更糟糕的斗争。我正试图制造一个有陷阱的游戏,如果玩家失败,他们会重生并且游戏会计算他们的死亡。我完全已经结束了,不知道从哪里开始。游戏是3D

    using UnityEngine;
    using System.Collections;

    public class Respawn : MonoBehaviour {
    public Transform spawnPoint; 
    public float minHeightForDeath;
    public GameObject player;

       void Start () {

       }
  // Update is called once per frame
  void Update () {
    if (player.transform.position.y < minHeightForDeath) {
        player.transform.position = spawnPoint;
    }
  }
}

2 个答案:

答案 0 :(得分:1)

在飞机/立方体上使用对撞机/任何适合您的对象,并将其设置为触发器。因此,当它们通过the trigger collider时,它可以记录它们并用它做你想做的事。

使用OnTriggerEnter方法脚本

"detail": "<h1>Overwatch Patch Notes – October 19, 2016</h1>\r\n\r\n<p>A new patch is now live on Windows PC. Read below to learn more about the latest changes.</p>\r\n\r\n<p>To share your feedback, please post in the <a href=\"http://us.battle.net/forums/en/overwatch/22813879/\" target=\"_blank\">General Discussion</a> forum.<br />\r\nFor a list of known issues, visit our <a href=\"http://us.battle.net/forums/en/overwatch/22813881/\" target=\"_blank\">Bug Report </a>forum.<br />\r\nFor troubleshooting assistance, visit our <a href=\"http://us.battle.net/forums/en/overwatch/22813880/\" target=\"_blank\">Technical Support</a> forum.</p>\r\n\r\n<p>Please note that these changes will be rolled into a larger patch for PlayStation 4 and Xbox One at a later date.</p>\r\n\r\n<h2>BUG FIXES</h2>\r\n\r\n<p><strong>General</strong></p>\r\n\r\n<ul>\r\n\t<li>Fixed an issue causing the default Overwatch spray to override a player’s chosen spray when watching a Play of the Game or Highlight</li>\r\n\t<li>Fixed an issue causing players to frequently disconnect while viewing Highlights</li>\r\n\t<li>Fixed a bug preventing the appropriate music from playing after a loss on the Junkenstein's Revenge Brawl</li>\r\n</ul>\r\n\r\n<p><strong>Gameplay</strong></p>\r\n\r\n<ul>\r\n\t<li>Fixed a bug causing multiple issues when displaying data on the leaderboards</li>\r\n</ul>\r\n\r\n<p><strong>Heroes</strong></p>\r\n\r\n<ul>\r\n\t<li>Fixed an issue preventing Ana’s Nano Boost callouts from being heard by the enemy team</li>\r\n\t<li>Fixed a bug preventing players from receiving credit toward the Healing Done commendation when healing D.Va’s mech</li>\r\n\t<li>Fixed a graphical issue that was preventing the liquid in Mei’s Endothermic Blaster from appearing</li>\r\n\t<li>Fixed a bug causing Reinhardt’s Charge to unexpectedly stop when crossing certain thresholds (e.g. when exiting a dropship)</li>\r\n\t<li>Increased the volume of Roadhog’s “Want some candy” voice line</li>\r\n</ul>\r\n\r\n<p><strong>Map</strong></p>\r\n\r\n<ul>\r\n\t<li>Fixed a bug on Eichenwalde that caused some textures to stretch across the map for some players</li>\r\n</ul>\r\n".

答案 1 :(得分:0)

您没有在“minHeightForDeath”浮动中放置任何数据。除非你在编辑器中这样做。

除此之外,您是否已将脚本放在播放器gameObject上?你有没有在编辑器中设置你所拥有的东西?