Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Question about transfering methods between instances of an object
Old
711
Guest
 
Status:
Posts: n/a
Question Question about transfering methods between instances of an object - 11-14-2009, 09:53 AM

I have a few identical zombies in my world, and I decided they all need to have another method defining something about the way they move. I created this method using the first one, "zombie", and it looks like this:



However, zombie2, zombie3, zombie9001 etc all need this method too.

Is there anyway I can copy the method into the other instances of "zombie" and have it replace "zombie" with "zombie2" or "zombie3" in the code without me having to click 48 times extra for each zombie?

Note: deleting each instance and recreating using duplicates is not an option, as each unique zombie has it's own already defined additional variables.

Thanks in advance.
   
Reply With Quote
Old
kylefwlr
Guest
 
Status:
Posts: n/a
Default 11-14-2009, 11:32 AM

if you try and copy that into methods inside other objects i think it's only going to make the first zombie do that times however many times you call it, you have to change each zombies movements individually as far as i know
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 11-14-2009, 12:35 PM

There's a way to avoid it, but you'll have to rewrite the zombie method (however, you'll only have to re-write it once).

Create an object parameter called "zNum," inside your method. Then, click a zombie, click the functions tab, and scroll down to the very bottom of the list. You'll see one called "zombie's part named key" or something similar. Drag that over the names of the parts in your method that move (like body.rightleg) and type in the name of the part (like Body.RightLeg, make sure the capital letters are the same). Now, drag the object parameter over the zombie in that function so it reads "zNum's part named Body.RightLeg move down 10..." Do that for the rest of the actions in your method and you can have all the zombies do this method by calling it and setting the parameter value to the zombie you want to perform the method.


(')>
   
Reply With Quote
Old
711
Guest
 
Status:
Posts: n/a
Default 11-15-2009, 12:03 AM

Thanks! That's exactly what I wanted to know!

Also, resident penguin was pretty great. You're an excellent person to have posting here.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.