how do i pick up and throw objects

Non-platform specific questions.

how do i pick up and throw objects

Postby pikapika » Sun Oct 16, 2011 4:53 pm

hi im making a platform game an im wondering how to make it so that when you press a certain key only when your actor is standing on top of a certain object, you can pick up the object and by releasing the key throw the object at the enemy.
please post an answer in the box below
pikapika
 
Posts: 10
Joined: Wed Oct 12, 2011 12:06 am
Score: 0 Give a positive score

Re: how do i pick up and throw objects

Postby EvanBlack » Sun Oct 16, 2011 5:33 pm

Well first you need to check if you are colliding with the top of the actor, checking if player y + playerheight/2 < object y - objectheight/2, on keydown of specific key. Then change animation to pick up object, turn off collision, move object up above player, so the player is holding it.

Press key down, change animation to throw animation, move change object xvelocity, yvelocity, and have it constantly degrade over time or until collision with enemy. Change animation of enemy, destroy object.

if you want you player to move while holding the object you have to lock the x and y axis to the player using a pointer reference. Check out this page for details on using pointers to get x and y of another actor and reference it to a different actor : viewtopic.php?f=1&t=11162
(\__/) ( Soon... The world)
(O.o )< will be mine!____)
(> < )
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Bunny Overlord 2012!
EvanBlack
 
Posts: 202
Joined: Fri Sep 30, 2011 10:17 am
Score: 19 Give a positive score

Re: how do i pick up and throw objects

Postby pikapika » Wed Oct 19, 2011 5:46 pm

so what am i supposed to do to pick up and through objects in the game
pikapika
 
Posts: 10
Joined: Wed Oct 12, 2011 12:06 am
Score: 0 Give a positive score

Re: how do i pick up and throw objects

Postby skatermichael » Sat Nov 12, 2011 9:45 pm

ok so what i do is create a whole other actor called like "playerbox" with an animation of a player holding a box...
put that actor off screen.now with your player on collision of like a box destroy box create actor playerbox then destroy actor player....
now on playerbox actor key down say space create actor box destroy playerbox and create player...nowon box create actor script editor put somthing like this...you can tinker with the numbers to get what you need.
Code: Select all
xvelocity = xvelocity + 4//add anynumber you need here
yvelocity = yvelocity + 2//tinker with the number

and then on box collison of the ground destroy actor box.

i think this would be correct just correct me if this is wrong.
skatermichael
 
Posts: 1
Joined: Sat Oct 22, 2011 9:15 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest