playMaker

Author Topic: Creating a 2D "slinging" mechanic  (Read 1987 times)

youngjay_12

  • Playmaker Newbie
  • *
  • Posts: 1
Creating a 2D "slinging" mechanic
« on: November 12, 2018, 06:51:23 AM »
I’m trying to make a mechanic (which is similar to Spider Man's web slinging) in a 2D project I’m working at college and I’m having problems projecting my idea into unity and playmaker.

The mechanic is for a whip slinging mechanic where the player character uses a whip to latch onto certain points in the scene I’ve simply labeled ‘Latch Points’. The point of the mechanic is to get the player to higher points in levels and over large distances.
The issue is I can’t seem to apply a force in the X & Y axis at the same time using ‘Apply force 2d’
If i do it just seems to move in one direction.

Can anyone give me any other ways of adding a force in 2 directions at the same time?

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Creating a 2D "slinging" mechanic
« Reply #1 on: November 12, 2018, 01:45:11 PM »
The name of such mechanics is typically rope swinging of grappling hook. It can be done in a number of ways, each leading to a different behaviour. Typically, it’s done using joints. You can find dedicated scripts and tutorials on that.

A simpler method could be the “move towards action”. First, find the next latch point in viewing direction, store that latch game object, and then in the next state, move towards it. The graphical representstion (i.e. the “rope”) is often done with the line renderer component.

I tried a few versions, including with a distance joint, for which I made the action, but in the end used the move towards version (still to polish).

Found a bit here:
https://gamedevelopment.tutsplus.com/tutorials/swinging-physics-for-player-movement-as-seen-in-spider-man-2-and-energy-hook--gamedev-8782

These were useful to me to understand the concepts:
etc.
« Last Edit: November 12, 2018, 01:47:34 PM by Thore »