Hi I’m working on a platformer game with touch controls. I am trying to get my character to move when pressing the touch controls.
Here is the script Character_Move (C# and attached to touch controls)
using UnityEngine;
using System.Collections;
public class Character_Move : MonoBehaviour {
// Update is called once per frame
void Update ()
{
//Is there a touch?
if(Input.touches.Length <= 0)
{
//If no touches...
}
else //If screen touched..
{
//Loop through these
for(int i = 0; i < Input.touchCount; i++)
{
//executes this code for current touch
if(this.guiTexture.HitTest(Input.GetTouch(i).position))
{
//If current touch hits the guitexture...
if(Input.GetTouch(i).phase == TouchPhase.Began)
{
GameObject.Find("Blorade Char").GetComponent.CharacterManager<MovementTriggered> = true();
}
if(Input.GetTouch(i).phase == TouchPhase.Ended)
{
}
}
}
}
}
}
Here is the script CharacterManager (C# and attached to My character)
UnityEngine;
using System.Collections;
public class CharacterManager : MonoBehaviour {
public bool MovementTriggered = false;
void Update()
{
if(MovementTriggered == true)
{
transform.Translate(5f * Time.deltaTime, 0f, 0f);
}
}
}
With this line:
GameObject.Find("Blorade Char").GetComponent.CharacterManager<MovementTriggered> = true();
I tried to make a Boolean in CharacterManager for my character to move when the boolean is true So I am making it true with this line but it wont work.
Errors:
Expression denotes a ‘value’, where a ‘method group was expected
and
Expression denotes a method group', where a
variable’, value' or
type’ was expected
I have tried to fix this in many ways so If you could help me access the boolean correctly or Something else to make the character move on trigger that would be great.
Thankyou