- Home /
How can i make my Player stick/roll around on walls
How can I make the player (The circle with wheels) be able to stick and roll around on different surfaces like a wall or a ceiling
Answer by Dailyalex · Jan 14 at 02:44 PM
Couple of ideas which you could try:
1) if this circle is single rigidbody in game (with use gravity checkbox checked) you could change gravity from Y to X axis, when you collide to wall (depending on side)
2) you can add constant force to rigidbody ( rigidbody.AddForce
with Vector.up
and ForceMode.Force
or ForceMode.Acceleration
parameters (depends if you want to ignore mass or not). And maybe also add slightly force to wall direction (to make it stick to it)
Okay, I see what you mean now. For now I am just going to stick to making the gravity change from 1 to -1. I am trying to do the first method and I have an idea on how to do it. Whenever the Player the touches the purple cube (Gravity Square) the player's gravity will change from 1 to -1. I just need to now how to implement one last line of code and I think i'l be good.
The script for the gravity square looks like this.
using UnityEngine;
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) {
}
}
} this is currently my player Movement script
using UnityEngine;
public class Movement : MonoBehaviour { public float MovementSpeed = 1000f;
void Update()
{
var movement = Input.GetAxis("Horizontal");
GetComponent<Rigidbody2D>().angularVelocity = -(MovementSpeed*movement);
}
}
I just need to figure how to change the player's rigidbody gravity between the curly brackets under the if (other.CompareTag("Player))
also thanks for helping me :)
Your answer
Follow this Question
Related Questions
Object collision 2 Answers
Wall running using raycasting. 2 Answers
AI GameObjects Go Through Walls? 1 Answer
Raycast detects walls, how to disable movement or input in direction of the wall? 0 Answers
Wall Climbing and Default Gravity 1 Answer