Hello, thanks for visiting GameML, if you are a Game Maker user, this is the site for you, please sign up, or login if you are already a member, or just browse the site! Welcome to GameML!

ATTENTION MEMBERS!!! USERS CAN NOW SIGN UP AGAIN!
Log in

I forgot my password

Search
 
 

Display results as :
 


Rechercher Advanced Search

Site Hits
Free hit counter
These stats started at 0 on July 7th 2009
GameML File Sharing
USERNAME: gamemladmin@gmail.com PASSWORD: gamemlsite Upload Here: http://gameml.iowoi.org/GameML-File-Sharing-h3.htmPlease add only games.
Create A GAMEML BLOG!
Make a Blog on GameML:http://gamemlblogs.wetpaint.com
Keywords


why use parenting?

View previous topic View next topic Go down

why use parenting?

Post by slayer 64 on Sun Jul 05, 2009 9:47 am

parenting is useful when you want to have alot of objects that do almost the same thing. or when you want to the same with a bunch of objects but don't feel like copying and rewriting code for them all.
you should read "More About Objects" in the gm manual. if you haven't read it, go read it now.

i want to make a 3d game. i want solid objects but when i use gm's build in solid, the player will be moved to its previous position when it collides with a wall. i will make a parent object called par_solid so i can do collision checks with any of its children. par_solid objects will use their sprite, a z, and a height variable. i set those varibales in the create event of the children.

i want the player to slide smoothly. i will make a 2 scripts, d3d_instance_place and reduce.
d3d_instance_place
Code:
//
//  Arguments:
//      x
//      y
//      z
//      obj
//
//  Returns:
//      whether the instance placed at position (x,y,z) meets obj.
//      obj can be an object in which case the function returns
//      true is some instance of that object is met. It can also
//      be an instance id, the special word all meaning an
//      instance of any object, or the special word other.
//
//  slayer 64
//

with(argument3)
{
    with(other)
    {
        if place_meeting(argument0,argument1,other)
        if argument2+height-1>=other.z
        if argument2        <=other.z+other.height-1
        if id!=other.id
            return 1;
    }
}
return 0;
reduce
Code:
//
//  arguments:
//      number
//
//  returns:
//      the number reduced closer to 0
//
//  slayer 64
//

return floor(abs(argument0)/2)*sign(argument0);
i will use these scripts in collision checks from the end of the step event.
step
Code:
while(d3d_place_meeting(x+hspeed,y,z,par_solid))
{
    hspeed=reduce(hspeed);
    if hspeed=0 break;
}
   
while(d3d_place_meeting(x+hspeed,y+vspeed,z,par_solid))
{
    vspeed=reduce(vspeed);
    if vspeed=0 break;
}
   
while(d3d_place_meeting(x+hspeed,y+vspeed,z+zspeed,par_solid))
{
    zspeed=reduce(zspeed);
    if zspeed=0 break;
}

the while loops say, "while there is a solid ahead of me, reduce speed. if i'm stopped, stop the loop."
using the par_solid object i can make children that are different sizes and i won't have to do any more coding or collision events. here is an example gmk that uses this technique.
learn 3d example
i will make this post better if it is confusing.
avatar
slayer 64
GameML Noob
GameML Noob

Posts : 20
Points : 30905
GameML Reputation : 8
Join date : 2009-07-05
Age : 28

View user profile

Back to top Go down

Re: why use parenting?

Post by -js1210- on Sun Jul 05, 2009 11:13 am

Whoa! Slayer 64 joined! Now we have some people that actually know about GameMaker Smile This looked like a pretty in depth desription, but I can't really tell because I know nothing about 3D programing.
avatar
-js1210-
Super 500 GML
Super 500 GML

Posts : 1298
Points : 33292
GameML Reputation : 27
Join date : 2009-06-02
Age : 22
Location : United States

View user profile http://www.yoyogames.com/members/js1210

Back to top Go down

Re: why use parenting?

Post by 3d on Sun Jul 05, 2009 1:47 pm

It is good, parenting is a great thing to do in 3d games, which im adding to mine now.

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 42926
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: why use parenting?

Post by 3d on Sun Jul 05, 2009 1:48 pm

and i invted him, hes my friend on yoyo.

_________________
Creator of GameML, Thanks for Visiting!
avatar
3d
Admin
Admin

Posts : 1227
Points : 42926
GameML Reputation : 66
Join date : 2009-05-31
Age : 35
Location : U.S.A

View user profile http://gameml.iowoi.org

Back to top Go down

Re: why use parenting?

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum