Jump to content


Photo

Object_ Get And Set Re: Parent And Solid


  • Please log in to reply
4 replies to this topic

#1 Trinnexx

Trinnexx

    GMC Member

  • GMC Member
  • 46 posts
  • Version:GM:Studio

Posted 06 June 2013 - 09:05 PM

I have created a platforming player that gets its movement in the begin step phase.

Movement is introduced via hspeed & vspeed.

Gravity is introduced via the in-built gravity system.

Collisions are handled during End step and work perfectly against solids.

 

In order to create jump-thru platforms I created the following code that is executed during a collision event with the jump-thru platforms.

 

//convert collided plat to solid if needed
x= xprevious; y= yprevious; //required

if (bbox_bottom < other.bbox_top + 23 && vspeed >= 0)
{

    with (other)
    {
        sprite_index = S_solidplat;
    }
    object_set_solid(other, true);
    object_set_parent(other, W_wall);
    
    move_contact_solid(direction, speed); //required
    vspeed = 0; //required
    
} else {
    
    with (other)
    {
        sprite_index = S_nonsolidplat;
    }
    object_set_solid(other, false);
    object_set_parent(other, oNull);
}

I would imagine this puts the player back to its position before collision and makes other solid and a W_wall type (used for end step collisions). The visual aid (changing sprite) shows it to be working correctly. However the player is at any time able to pass horizontally though the platform as if it is not solid at all (and remains suspended in air by it). The player if falling from a great height appears to 'Bounce' on the platform occasionally before coming to rest (this bounce effect is a common repeating problem I have with creating collision code myself).
 

Attempting to show_debug_message string(other.solid) always returns 0. Attempting to show_debug_message string(object_get_solid(other)) always returns -1.

 

without the move_contact_solid and x = xprevious etc the player can penetrate the ground slightly on collision.

without the vspeed = 0 the player passes straight though the floor as if it were not solid (even though it is being set to solid and collision with solid W_wall types are resolved in end step)

 

Are these Set functions suppose to be applied immediately? If not, when do they take effect?

 

*somehow* one of my platforms is magically linked to another one (this is incredibly bizarre behaviour) and a side collision with the first platform changes the state (to nonsolid) of another platform that is 4 blocks away. The only thing I can think of is the player is shooting across the screen and touching it, but the movment is unseen due to the use of x = xprevious etc. Changing the move contact_solid to a downward movement only stops this effect.
 

Why do moving objects appear to 'bounce' at higher speeds against solids when they include a collision event? Does a collision event automatically do a move_contact_solid or alter the position or speed behind the scenes?

 


  • 0

#2 TimothyAllen

TimothyAllen

    GMC Member

  • GMC Member
  • 2537 posts
  • Version:GM:Studio

Posted 06 June 2013 - 09:17 PM

object_set_solid and object_set_parent will have NO affect on instances currently in the room.


  • 1

#3 Trinnexx

Trinnexx

    GMC Member

  • GMC Member
  • 46 posts
  • Version:GM:Studio

Posted 06 June 2013 - 09:28 PM

Ah, it even says in the help. Silly me. Changing the solid flag to true directly seems to stay set but without being able to change the parent (or whether setting solid on an active instance actually makes it solid) I'm not sure what I can do from here as the point of having parent based detection was to allow the player to pass upwards through a platform but not down AND sideways though one that is above feet height.


Edited by Trinnexx, 06 June 2013 - 09:35 PM.

  • 0

#4 GameGeisha

GameGeisha

    GameGeisha

  • GMC Member
  • 4092 posts
  • Version:GM:Studio

Posted 06 June 2013 - 09:37 PM

You can make an instance solid by setting solid to true, but you cannot change the parent of an instance.

 

GameGeisha


  • 0

#5 Trinnexx

Trinnexx

    GMC Member

  • GMC Member
  • 46 posts
  • Version:GM:Studio

Posted 09 June 2013 - 06:24 PM

I actually got a lot of progress out of setting other.solid, thanks!


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users