DevLog 4.1.3 Input.GetMouseButton is Long Press

DevLog 4.1.3 Input.GetMouseButton is Long Press

Welcome, Welcome So I have Spent a while Trying to Get this to work but one thing I Have understood is that for a beginner one Needs to Work on Mechanics then Design, However I have been working on Mechanics for about a week and a Half in unity, Yes it is hard. Lets Discuss the Title For a Bit, So one thing i have noticed is that some people who develop for unity are not always advanced, They Seem to be stuck in this always in intermediate type of loop not always but some. It is kinda weird that this function has been around for a long time, yet i didn't even know what this Did. This is though Partly Unity's Fault as the term GetMouseButton sounds like a click and GetMouseButtonDown sounds like a Mouse Hold.

The next thing i have to figure out is a Double Click or Something along those lines and use that for a Ground Pound and Rotation of character.

Here is The Code That is Giving me Problems and at the same time is part of a solution

C#

Vector3 direction = target.transform.position - transform.position;

RaycastHit2D hit = Physics2D.Raycast(transform.position, direction, Mathf.Infinity, GroundLayer);

transform.rotation = Quaternion.FromToRotation(transform.up, hit.normal) * transform.rotation;

Physics2D.gravity = -hit.normal * force;        

and Here is The Mouse hold code

C#

if(Input.GetMouseButton(0)) {
      rigidbody.velocity = (Vector3)(transform.right * .5f);
      /*float LastClickTime = Time.time - SecCount;
      if(LastClickTime <= clickPress){
        transform.Rotate(new Vector3(0f, 180f, 0f));
      }
      SecCount = Time.time;*/

}        

and If you want to look at the whole file Then Check The StarCatcher C# file channel (link above)

要查看或添加评论,请登录

社区洞察