- Home /
The question is answered, right answer was accepted
Object move without an input
Hello I'm working on a game My problem is that my player moves without any influences and the script cannot be because it moves without the script.
Could it be that the mesh collider is causing it? How can i fix it? (I'm sorry if someone posted it before, but I can't find it)
What is in your Jump.cs script it might be trying to jump causing it to slide
Answer by Dark_Games_Studios · Feb 08, 2021 at 07:28 PM
That does not work either I noticed that it only occurs when I have a mesh colider. And when i turn kinematik on it doesn´t it but i gos through walls. I noticed that when I increase the mass a little the error occurs when I move the object but it moves through the walls. But thanks Here is the code i use
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement_night : MonoBehaviour
{
public float speed = 5;
public float speed1 = 10;
Vector2 velocity;
void FixedUpdate()
{
if (Input.anyKey)
{
velocity.y = Input.GetAxis("Vertical2") * speed * Time.deltaTime;
velocity.x = Input.GetAxis("Horizontal1") * speed * Time.deltaTime;
transform.Translate(velocity.x, 0, velocity.y);
}
}
void Update()
{
if(Input.GetKey(KeyCode.LeftShift))
{
velocity.y = Input.GetAxis("Vertical2") * speed1 * Time.deltaTime;
velocity.x = Input.GetAxis("Horizontal1") * speed1 * Time.deltaTime;
transform.Translate(velocity.x, 0, velocity.y);
}
}
}
It work i did if press any key (kinematic false;) else kinemetik true;
Follow this Question
Related Questions
Moving Platform Collisions with Custom Movement Script 0 Answers
How to let the player collide with animated objects? 0 Answers
How to detect player collision 0 Answers
How to make a 2D "trampoline"? 2 Answers
OnControllerColliderHit function is not called if player is not performing a move. 2 Answers