playMaker

Author Topic: Restart Level  (Read 4620 times)

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • my twitter @andrewlukasik
Restart Level
« on: October 17, 2011, 05: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, 07:32:20 AM by Andrew_Raphael_Lukasik »

Alex Chouls

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

nabilfx

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


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 5067
    • View Profile
    • jinxtergames
Re: Restart Level
« Reply #3 on: October 11, 2015, 03: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