The Daily Click ::. Forums ::. Klik Coding Help ::. Linking two objects.
 

Post Reply  Post Oekaki 
 

Posted By Message

Matt Gardner



Registered
  07/10/2002
Points
  14
13th August, 2006 at 19:58:57 -

I'm working on a game where I have two objects which represent each enemy. There's the actual enemy, and their shadow. Although the shadow is the more important one as the events all happen to it, the enemy is basically just there as a visual graphic

I link them together so they won't react to something happening to another instance of the same object with the following:

Pick one of (shadow) + Pick one of (enemy) + (enemy) is overlaping (shadow) + alt val Z of (enemy) is 0 + (shadow) flag 99 off = turn (shadow flag 99 on + set (enemy) alt val Z to (shadow) fixed value

(the flag 99 part is to make sure the shadows don't get assigned to more than one enemy)


Then whenever I need to have an event involving the enemy, to make sure if only affects the shadow in question and the associated enemy, so I include the following qualifiers into the event:

pick one of (enemy) + pick one of (shadow) + alt value Z of (enemy) = (shadow) fixed value

and add whatever the rest of the event is.


This works fine, but the more enemies there are the choppier the actions work.

Is there a more streamlined way to do this that anyone knows of?

 
It's Gravy!

DanielRehn



Registered
  18/09/2002
Points
  139
13th August, 2006 at 21:27:34 -

That's beacuse you randomly pick objects and check if the values match...


pick one of (enemy) + pick one of (shadow) + alt value Z of (enemy) = (shadow) fixed value


Remove the picking events


alt value Z of (enemy) = (shadow) fixed value


should work better!

 
n/a

Matt Gardner



Registered
  07/10/2002
Points
  14
14th August, 2006 at 00:07:28 -

I've tried doing it without the 'pick' portions but then it perfoms the actions on all instances of the enemies on the screen.

Is there a way to stop this from happening?

 
It's Gravy!

Matt Gardner



Registered
  07/10/2002
Points
  14
14th August, 2006 at 01:27:44 -

Here's an example of the problem I'm having.

One is it being chopping with the 'pick one' statement
One is it without the 'pick one' statement where only one of the enemies follows the shadow

They're saved as MMF2 files, I can't compile them until I receive the full version in the mail, at the moment I'm just running the demo.

http://www.floatinghandsstudios.com/games/shadowproblem.zip

If anyone knows a sufficient way to solve this please let me know.

 
It's Gravy!

Werbad



Registered
  18/09/2002
Points
  235
14th August, 2006 at 10:08:26 -

If it's just for positioning:
* Always
- "Character" Set position at (0,0) from "Shadow"

But if you need to change animations and such on the enemy, it's easier to loop through all shadows and individually change them

Could be done like this:
* Always
- "Character" Spread value 0 in Alterable Value Z
- "Shadow" Spread value 0 in Alterable Value Z

* Always
- Start loop "ShadowLoop" NObjects("Character") times

* On loop "ShadowLoop"
+ Aterable Value Z of "Character" = Loopindex("ShadowLoop")
+ Aterable Value Z of "Shadow" = Loopindex("ShadowLoop")
- "Character" Set position at (0,0) from "Shadow"

Note that there must be 2 different Always events, atleast in MMF 1.5

 
n/a
   

Post Reply



 



Advertisement

Worth A Click