playMaker

Author Topic: Pick up and visually carry object  (Read 7592 times)

parnell

  • Playmaker Newbie
  • *
  • Posts: 8
Pick up and visually carry object
« on: January 06, 2013, 02:44:25 AM »
So I'm toying around with a 2.5d possible 3D platformer styled game.  I just picked up Playmaker and I've ran though a bunch of tutorials over the last week or so and haven't found any that help with the type of controller I'm planning.

The Character Controller I'm playing with right now can walk, run (with shift pressed), jump and attack. I'd also like to implement a pick up object command and I'd like to implement a roll/dodge move but I've no idea how.  I currently have something in and working for the pick up, however there are issues with it and I'd appreciate some help.

Controls are fairly straight forward
WASD, space to jump, shift + movement for sprint, Left Click for Attack, Right Click to pick up object in range.
http://www.subshape.com/wip4/wip4.html

What i'd like the character to do:

1. The player presses the right click and it parents the box to the player, preferably to a hand bone and a "carry animation" will play. This animation will also blend when the player runs around so that the object is still looking like it's carried and the legs are moving as well.
2. When the object is in a carried state the player cannot attack.
3. When the box is picked up the carried object should not penetrate into the enemies, slopes/stairs, walls, and other boxes.  Essentially, the box should still maintain it's collision, or at least look/act like it does without messing up the movement of the player.
4. The player can only carry one object at a time, and if 2 objects are practically the same distance it should pick the closer. (Possibly I could run a raycast and target the object that can be picked up).

So try playing the demo that I have so far.  I'm still trying to decide how I'll do melee combat.  I'm considering a sphere cast. 

Any help would be great.
B

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pick up and visually carry object
« Reply #1 on: January 07, 2013, 03:09:47 AM »
Hi,

 It would be great if you can cut down your set of features into distinct post, it will be easier to maintain and focus on a particular feature or problem for each post,

Thanks :)

bye,

 Jean

parnell

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Pick up and visually carry object
« Reply #2 on: January 07, 2013, 12:54:09 PM »
Understood.

The problem I have is when I pick up the box I remove the boxes collider.  I do this so that the player can still move.  However, the box will collide through walls, slopes and other objects.  When I release the box I return physics, and the collider to the box but this can be an issue if it's inside another object, wall, etc. 

When the box is picked up, how do I make the collision of the box still work with the environment but not cause issues with the character controller?

Does this make sense?
Thanks
B

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: Pick up and visually carry object
« Reply #3 on: January 07, 2013, 08:54:16 PM »
Off the top of my head I would try adding invisible box collider(s) to the outside edge(s) of the boxObject that is not touching the character, these collider(s) would of course be parented to the boxObject.  You could turn them on and off if you had to depending upon the complexity your going for.

An example of this might be, say the boxObject could be grabbed by any of its 6 sides you could have a trigger in each collider on each side which could turn off when the said side was grabbed and would turn back on when it was dropped.

There may be a simpler way of going about this, like i said this idea is off the top of my head, and I'm still a noob myself.  But perhaps this will give you another angle to approach your problem, good luck.

parnell

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Pick up and visually carry object
« Reply #4 on: January 08, 2013, 03:13:08 AM »
Thanks for the idea.  However, I was able to clean things up a bit with a simple raycast.  This solved multiple issues with picking up the object. So I probably won't go with the box having multiple colliders on the box.  Sadly the problem still remains with the object having issues with walls when it's picked up.  I looked into Collision layers but it doesn't seem to be available to work with in Playmaker. ie: i can't swap the Box to suddenly not have collision with the player layer but still retain collision with the walls.

Any other ideas?
Is there a way to swap collision layer settings from Playmaker?
Thanks!
B

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: Pick up and visually carry object
« Reply #5 on: January 08, 2013, 04:40:05 AM »
Have you considered using a rigibody character, instead of the character controller? I needed a break from wrapping my head around my own work so I tested a similar scene to yours with a rigibody character and it seems to work fine for me.  If you want to go that route, all you need is 1 box trigger slightly bigger than and around the box you want to pickup and move. The rigibody character will pass through the box trigger but not the box itself, once parented the box will still keep its collision and collide with other objects and shouldn't interfere with your character.  Depending on the grab animation you use you may also want to child an empty object to your player that your movable box will be parented to. Maybe place the empty object evenly in front and between both your characters hands or fine tune its position however you see fit.  Not sure if this idea interests you, but there you go.  ;)

parnell

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Pick up and visually carry object
« Reply #6 on: January 08, 2013, 09:23:52 AM »
So if both the player and box are rigidbodies, and I parent the box to the front of the character then run into a wall will the box hit the wall and cause the player to stop moving?  Right now, I've got the player and box playing nice.  However, the minute I run into a wall carrying a box, the box and character collide and begin to intersect and do weeeird things.
I'll look into a rigid body character setup, are they any tutorials on how to setup one?  Most tutorials just have you slap on a character controller.
Thanks!
B

Justin

  • Junior Playmaker
  • **
  • Posts: 58
Re: Pick up and visually carry object
« Reply #7 on: January 08, 2013, 04:04:27 PM »
You will probably want to look over this http://docs.unity3d.com/Documentation/Components/class-Rigidbody.html and experiment with different settings of the rigibody the mass the drag the constraints and whether kinematic is turned on or off.  Again this is just a suggestion from a beginner to a beginner, there may still be better ways to handle your particular situation.  I'm not sure about the tutorials.  In the game I'm working on I use the set velocity action to move my rigibody character around, although my game does take place in outer space and not on the ground.

parnell

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Pick up and visually carry object
« Reply #8 on: January 08, 2013, 04:32:58 PM »
The demo up above kind of gives a look of what I'm planning.  Basically, a game where the player can pick up, drop, and stack blocks as well as do a simple melee attack ( i might make this a projectile). 
Character controller is what I've been using as it's the easiest to get things going.
Thanks for the links I'll keep you posted.
B