- Home /
Create movement like in getting over it with bennett foddy
I've been learning to program in c# using UnityEngine for a few days now and I'm trying to create a 2D game around the concept of moving like in the game "getting over it" by Bennett foddy, I was able to make the "arm" follow the mouse cursor using this script :
using UnityEngine;
public class ArmRotation2 : MonoBehaviour{
Vector3 mousePosition;
public float moveSpeed = 0.1f;
Rigidbody2D Player;
Vector2 position = new Vector2(0f, 0f);
private void Start()
{
Player = GetComponent<Rigidbody2D>();
}
private void Update()
{
mousePosition = Input.mousePosition;
mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
position = Vector2.Lerp(transform.position, mousePosition, moveSpeed);
}
private void FixedUpdate()
{
Player.MovePosition(position);
}
which looks like so :
In the beginning when i implemented the arm movement script it was pulling the rest of the character along and went flying but i fixed that by increasing the mass of the crate.
but now when i push the arm into the ground the Character ( crate ) does not get pushed up like i was hoping it magically would even tho i knew that that would be way to easy.
the arm segments are connected with 2D Hinge Joints and work the way they should.
I thought of coding the proper movement into my game by detecting the force the hand is applying onto a collider and then applying the same force onto the crate in the opposite direction, not that I know exactly how to code that but it's just a beginner's idea. And that's why I'm here to ask if this is a proper solution and how to execute it or if there is anyone who has created a movement script like this and would like to give me some help. and just fyi basically everything i learned on coding is from Brackey's youtube tutorial on how to make a game in unity.