Page 1 of 1

Push/pull boxes.

PostPosted: Fri May 10, 2013 1:48 am
by Grynde
Greetings all. I have been able to answer most of my questions perusing the tuts and threads, however, I am at a loss in figuring out how best to allow my character to push/pull a box.

Initially, I tried collision (which allows me to push but no pull).

Feeling smart, I then attempted to change the parent with a button down command. But that allows me to grab the box from anywhere on screen.

I imagine it is a hybrid of the 2 concepts, but I will take any and all advice you guys are willing to throw my way.

Cheers.

Re: Push/pull boxes.

PostPosted: Fri May 10, 2013 2:11 am
by Hblade
Do the button but only on collision using:
Code: Select all
char*key=GetKeyState();
if(key[KEY_SPACE]==1)
{
 change parent
}

Re: Push/pull boxes.

PostPosted: Fri May 10, 2013 6:16 pm
by Grynde
Thank you Hblade.

All is working properly (in that regard at least) :wink:

Once I knew what was going on, I added a release as well.
Code: Select all
    char*key=GetKeyState();
    if(key[KEY_s]==1)
    {
     ChangeParent("Collide Actor", "Event Actor");
    }
    char*key=GetKeyState();
    if(key[KEY_s]==0)
    {
     ChangeParent("Collide Actor", "(none)");
    }


Re: Push/pull boxes.

PostPosted: Fri May 10, 2013 11:55 pm
by Hblade
No need for 2 char*keys :) Just the top one

Re: Push/pull boxes.

PostPosted: Sat May 11, 2013 1:00 am
by Grynde
Fantastic. Thanks so much.

Re: Push/pull boxes.

PostPosted: Sat May 11, 2013 7:14 am
by Hblade
Your welcome =D