- Home /
Problem is not reproducible or outdated
CharacterController 2D Move called on inactive controller but it is active...
This should not be that hard but for some reason it is, or am I forgetting how character controllers work?
This error makes no sense the controller is indeed active
The only components on the object are Transform(obviously), a sprite renderer, this script, and a character controller.
Any help would be much appreciated, i'm sure its something stupid i just missed though :)
Here is the script, and according to it line 35 is the issue
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveByClick : MonoBehaviour {
//Transform to move
public CharacterController objectX;
//Vector2 data
private Vector2 targetPos;
private Vector2 dir;
private Vector2 movement;
//How fast does the object move
public int speed;
//Camera to use
public Camera camera;
void Update()
{
if(Input.GetMouseButtonDown (0))
{
targetPos = camera.ScreenToWorldPoint (Input.mousePosition);
dir = targetPos - (Vector2)objectX.transform.position;
movement = dir.normalized * speed * Time.deltaTime;
}
if(movement.magnitude > dir.magnitude)
{
movement = dir;
}
objectX.Move (movement);
}
}
CharacterController.$$anonymous$$ove called on inactive controller UnityEngine.CharacterController:$$anonymous$$ove(Vector3) $$anonymous$$oveByClick:Update() (at Assets/Scripts/$$anonymous$$oveByClick.cs:35)
Is it possible this was called before the Controller got Start() called?
If not, can you post a screenshot of the inspector for the object while in play mode?
Wouldn't let me reply so gotta post here.
I never imported CharacterController it's just a component that has always been there, so does that mean it's outdated for this version of unity?
Hmm... never $$anonymous$$d. It might just be that you're using a 3D character controller on a 2D object? $$anonymous$$ight look here for more information.
Guess I could just do the old fanshioned rigidbody2d addforce then, if charactercontrollers aren't "compatible" with 2d object don't really see why they wouldn't though.
Follow this Question
Related Questions
Physics2D Overlapbox not working as aspected 0 Answers
Why is there no Rigidbody2D.SweepTest() ? 1 Answer
Stop jump animation 1 Answer
how to throwing/flick gameObject in 2D 1 Answer
Simulating a trajectory that takes collisions into account 2 Answers