playMaker

Author Topic: undo redo  (Read 3571 times)

3d_Artist1987

  • Beta Group
  • Full Member
  • *
  • Posts: 157
undo redo
« on: April 17, 2013, 03:23:36 AM »
hi,

In my game i want to add undo redo functionality,how to do this?

Dev

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: undo redo
« Reply #1 on: April 17, 2013, 03:41:27 AM »
you are gonna have to be more specific than this!

What type of game are you making?

What are they gonna undo / redo? (text?, spawning objects?, rewinding time etc?)

What have you already tried?
Remember, you don't fail unless you give up trying to succeed!

3d_Artist1987

  • Beta Group
  • Full Member
  • *
  • Posts: 157
Re: undo redo
« Reply #2 on: April 17, 2013, 04:02:16 AM »
hi,

thanks for reply.

i do many actions like activate game object,material change,GUI property changes,position,animation and ext.i try with global event but this is more time consuming.

Dev

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: undo redo
« Reply #3 on: April 17, 2013, 04:06:41 AM »
hi! This sounds like a huge thing to tackle with undo - I don't think that there is a specific system or action thats gonna help you with this

what i would do is just do it all manually, its gonna be a hell of a job but it CAN be done

What i mean with manually is, imagine you have 2 states. state 1 listens for a key (any key) and when that key is pressed it flows into state 2, that performs your action (activate gameobject, position change or whatever) and then in state 2, you add a listener for an "undo" key (E for an example) and when E is pressed, it flows back to state 1 where the original parameters are. This would be a primitive kind of undo i guess, or you could explore the "previous state" action that lets you jump back to the state it was in before the current state

Dont think i can help you any more than that, sorry

Hope you figure it out though! Good luck -

Fred
Remember, you don't fail unless you give up trying to succeed!

3d_Artist1987

  • Beta Group
  • Full Member
  • *
  • Posts: 157
Re: undo redo
« Reply #4 on: April 17, 2013, 04:36:02 AM »
hi,

thanks for your interest,i already doing this way,but so much time doing this.

dev

3d_Artist1987

  • Beta Group
  • Full Member
  • *
  • Posts: 157
Re: undo redo
« Reply #5 on: April 17, 2013, 11:49:19 PM »
bump  :(
« Last Edit: April 17, 2013, 11:51:18 PM by dev_xrt »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: undo redo
« Reply #6 on: April 18, 2013, 01:31:46 AM »
Hi,

 undo redo will be a huge task indeed, so you need to prepare yourself for a lot of work and experimentation!

 basically, on the few successful implementation I have seen around in various projects, I would recommend the following approach:

for each action that supports undo and redo, create one fsm to DO the action and one fsm to UNDO the action, and apply a strict naming convention for fsms naming like

DO - this
UNDO - this
DO - that
UNDO -that

then, you will need a high level controller that will record, for each of these actions, the parameters and have them listed in order of execution, so that you can undo and redo within that ordered list. the action itself will be respsonsible for feeding the hashtable of params, the high level controller must not know anything about what the action does or need, it simply needs to maintained that ordered list of actions so that when you do the Undo redo dance, it simply move up and down the list and call the actions.

 Using arraymaker is mandatory here :)

each action you perform will need to save its associated data in the controller so that when the user undo, you know both the action to undo AND the parameters associated: example:

 DO - move
UNDO - move

let's take this action, obviously it takes two parameters at least, the gameobject to move and the vector to actually move it to. so you save in the a hashtable in the controller for that action performed.

"action": "move"
"gameObject": -pointer-
"position":-vector3-

This hashtable proxy will then be saved in your arrayList representing your ordered list of actions. AND the fsm "DO - move" and "UNDO - move" must accept that hasthable reference so that it can retrieve and set its parameters, as only that action knows what to do with this.

When the user wants to undo, you take that last entry added to the list, and perform "UNDO-"+action passing that hashtable reference to it so that it can retrieve what it needs and perform the action.

It may sound difficult to implement, and guess what... it is... :) but it's doable. Interesting challenge I say!

Bye,

 Jean

3d_Artist1987

  • Beta Group
  • Full Member
  • *
  • Posts: 157
Re: undo redo
« Reply #7 on: April 18, 2013, 11:51:20 PM »
hi,

thanks jean for sharing information,i will try with Array maker.

Dev