playMaker

Author Topic: Restart Level  (Read 8260 times)

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Restart Level
« 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); }
}
}
« Last Edit: October 22, 2011, 10:32:20 AM by Andrew_Raphael_Lukasik »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4004
  • Official Playmaker Support
    • LinkedIn
Re: Restart Level
« Reply #1 on: October 17, 2011, 11:20:24 AM »
Nice one!

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Restart Level
« Reply #2 on: October 11, 2015, 04:00:14 PM »
How can i restart the level, with losing the information and objects i kill?


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7623
    • jinxtergames
Re: Restart Level
« Reply #3 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