Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: Andrew.Lukasik on October 17, 2011, 08:40:26 AM

Title: Restart Level
Post by: Andrew.Lukasik on October 17, 2011, 08:40:26 AM
RestartLevel.cs

Action to restart current level.

Description: Action restarts current level immediately using one line of code:
Application.LoadLevel(Application.loadedLevelName);

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
// micro script by Andrew Raphael Lukasik

using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Level)]
[Tooltip("Restarts current level.")]
public class RestartLevel : FsmStateAction
{
public override void Reset(){}
public override void OnEnter() {Application.LoadLevel(Application.loadedLevelName); }
}
}
Title: Re: Restart Level
Post by: Alex Chouls on October 17, 2011, 11:20:24 AM
Nice one!
Title: Re: Restart Level
Post by: nabilfx on October 11, 2015, 04:00:14 PM
How can i restart the level, with losing the information and objects i kill?

Title: Re: Restart Level
Post by: djaydino on October 11, 2015, 06:01:18 PM
Hi,
i believe local variables are reset but global variables are not
what you can do is @ the start of you game to set your globals or just before the "restart level" action