Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Objectmix  (Read 2657 times)

0 Members and 1 Guest are viewing this topic.
Objectmix
« on: April 24, 2011, 01:32:45 pm »
  • Let's do this.
  • *
  • Reputation: +4/-0
  • Offline Offline
  • Gender: Male
  • Posts: 211
Öhm... next problem, next question. XD
And here is the description:
I have an object.
If the object collides with a Boomerang then it creates stars above the object.
Now I have a second object in the map with the features of the first object.
And the second object creates the stars above the first object and not above itself. :-\
How I can stop this?
Logged
This is one of many tales Hylian lore speaks of...

Click here to check out my Deviantart!
  • Zelda Time Walker
Re: Objectmix
« Reply #1 on: April 25, 2011, 09:32:05 am »
  • AKA "Micah DS"
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1347
Now I have a second object in the map with the features of the first object.

Do you mean you're using parents? I'm not sure I understand what you mean here by having the "features of the first object".

From what you've said, the only thing I can think of is that the second object might be told to put stars above that first object by accident if you've copied code over from the first object into the second object that specifically tells to put stars above the first object. Or something along those lines. I can't really tell without seeing the code.


My questions for you:

Is your collision code placed in the boomerang object or in the first/second objects?
Did you copy over collision code that said to create the stars above the first object while forgetting to change it for the second object? That of course would make it create stars above the first object even if it was a collision with the second because the code in the second one still said to create stars above the first.


If I'm way off, showing your code would help me/others help you greatly.
Logged
  • My Music
Re: Objectmix
« Reply #2 on: April 25, 2011, 02:23:24 pm »
  • ...---^^^---...
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 616
Yeah, since there are multiple ways to do any one thing in game making it is difficult to know what you did without looking at it.  Like FrozenFire was stating we need to know a few things.  Is the second object a child of the first object.  Do you have a listed collission event in the boomerange object for both the second and first objects or only the first? (maybe the collision events are in objects 1 and 2 instead?)  If no parenting was used then is the second object just a copy of the first object...  In which case it would be easy to accidently forget to change something that would make this happen.  Are you using GML or D&D.  If it is GML post the code so we can look at it.
Logged
Re: Objectmix
« Reply #3 on: April 25, 2011, 03:30:48 pm »
  • Let's do this.
  • *
  • Reputation: +4/-0
  • Offline Offline
  • Gender: Male
  • Posts: 211
All monsters have one parent: Monsters_Par
If the Boomerang collides with Monsters_Par then it creates stars(object without parent) above Monsters_Par.
The collision code is placed in the Boomerang.
Logged
This is one of many tales Hylian lore speaks of...

Click here to check out my Deviantart!
  • Zelda Time Walker
Re: Objectmix
« Reply #4 on: April 25, 2011, 03:59:40 pm »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 446
So you're using a standard collision event where the Boomerang collides with Monsters_Par? And the problem is that the stars appear over the first monster you've created.

Is the code that creates the stars in the event something similar to this?

Code: [Select]
instance_create(Monsters_Par.x,Monsters_Par.y,objStar)

If so, then a fix would be this:
Code: [Select]
instance_create(other.x,other.y,objStar)
« Last Edit: April 25, 2011, 04:01:17 pm by Nabeshin »
Logged
Re: Objectmix
« Reply #5 on: April 25, 2011, 04:28:03 pm »
  • Let's do this.
  • *
  • Reputation: +4/-0
  • Offline Offline
  • Gender: Male
  • Posts: 211
Exact, this is the standart collision code.
I tried your code and then the stars were above the object that the boomerang collides.
I tried this with two objects. It worked with the first object but with the second object there was an error.
The Boomerang collides with the second object and then I saw the stars above the second object.
But only a short moment. After the short moment the stars were above the first object.
Logged
This is one of many tales Hylian lore speaks of...

Click here to check out my Deviantart!
  • Zelda Time Walker
Re: Objectmix
« Reply #6 on: April 25, 2011, 08:06:02 pm »
  • Let's do this.
  • *
  • Reputation: +4/-0
  • Offline Offline
  • Gender: Male
  • Posts: 211
Oh, I forgot to change the code of the stars. XD
Before:
Code: [Select]
x = Monsters_Par.x
y = Monsters_Par.y
Now:
Code: [Select]
x = other.x
y = other.y
Now the stars appear correct.
But although the new code is in the step event the stars don't follow the object. :-\
Logged
This is one of many tales Hylian lore speaks of...

Click here to check out my Deviantart!
  • Zelda Time Walker
Re: Objectmix
« Reply #7 on: April 25, 2011, 08:18:27 pm »
  • ...---^^^---...
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 616
That is because you are using the key word "other".  Using "other" in a collision event worked because during the collision the id of the object you were colliding with was stored in the key word "other".  This is not true for the step event.  If you want the stars to follow the certain object then you must store the id of that object in a variable and use that instead of the keyword "other"

For Example:

Collision event where the stars are created:
Code: [Select]
//create the stars
with (instance_create(other.x,other.y,Stars))
{
     //This code will store the id of the enemy you want the stars to follow in the variable Enemy_ID
     Enemy_ID = other.id
}

Step event in the stars object
Code: [Select]
//follow enemy
x = Enemy_ID.x
y = Enemy_ID.y

edit:  There is nothing special about the variable name Enemy_ID.  You can change it to whatever you want.
« Last Edit: April 25, 2011, 08:33:29 pm by Aero88 »
Logged
Re: Objectmix
« Reply #8 on: April 25, 2011, 11:49:56 pm »
  • d(-_-)b
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 36
I recommend you to check all possible collisions at the same time, this is what I would do:

For the boomerang code:
Code: [Select]
objectID = collision_rectangle(x1,y1,x2,y2,Monster_Par,precision,notme);

while(objectID > 0)
  {
  if(objectID.stunned == false)
    {
    newStar = instance_create(x,y,objectStar);
    newStar.FollowObject = objectID;
    objectID.stunned = true;
    };
  instance_deactivate_object(objectID);
  objectID = collision_rectangle(x1,y1,x2,y2,Monster_Par,precision,notme);
  };
 
instance_activate_object(Monster_Par);
This will also prevent the creation of multiple star objects, but you need to set the stunned variable in the creation code.

objectStar code:
Code: [Select]
x = FollowObject.x;
y = FollowObject.y;

yeah I hate the collision event x)
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.053 seconds with 55 queries.