Forum rules - please read before posting.

[2D] Make player push an object

edited August 2014 in Technical Q&A
I want to make my player push an object, such as a boulder. 
In the 2Ddemo Brain 'pushes' the tree swing.
I want however to move part of the scenery and leave it in the new position at the end of the cut-scene.

What would be the preferable method of doing this. Presently, as a place-holding test, I have simply keyed the object at the start to move position to the end. At the same time I have my player move to the new position. This will certainly not do for the finished game.

What do I need to consider?

Thanks anyone who can help.

Comments

  • You have a couple of options:

    1) Use the Object: Transform Action to move the object.  It has a few options regarding speed, etc, but doesn't offer the fine tuning of:

    2) Using the Object: Animate Action to animate the object's movement.  You have full control over the motion, because it's stored in an AnimationClip asset (like the tyre in the 2D demo)

    The key thing is that the position is recorded in saved games.  If it's a simple matter of it being in either "position A" or "position B", then you can attach the Remember Transform script to the object, and it's position will be recorded.
  • edited August 2014
    Thanks for the reply Chris.

    I am doing method 2 at present. One issue I have is this: with only a key from start to end the object doesn't move at the same rate as the player moves between start and end markers. By same rate I mean its inconsistent even though they start and end pretty much at the same position/time. Perhaps there's an anim "curve" involved in the player start/stop? the object move anims are straight lines with no easing on them.

    I haven't done anything in Mecanim besides make simple key frame anims as I would in Maya. I did see a way to layer and link 2D sprites in the Unity 4.3 2D functionality; I hoped someone might say 'that's how you nail an object to the player's hands properly' or something like that.

    If I have to manually edit the tangents as curves to match the player that will be a bit of a pain in the bum! :/
  • The player will move at a constant speed, except for a brief acceleration / deceleration at the ends.  Try modifying the movement values in the Player inspector to see if you can get the correct effect.
  • Thanks Chris

    Am I right in thinking these movement values can't easily be altered without some additional coding?

    If so then perhaps it would be easier to manipulate the start/end curves of the motion to match better the start/stop speed of the player.
  • edited August 2014

    They're public variables in the Player script (actually the Char script, which is the base class).  A simple script is all that's needed to override them:

    void ChangeAcceleration (float newValue)

    {

      GetComponent <Char>().acceleration = newValue;

    }

    Know that a deceleration value of 0 will make AC just use the accelaration value for both.

  • Brill, thanks Chris.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.