実現したいことここに質問の内容を詳しく書いてください。
(例)
unityでマリオのような2dアクションを作っているのですが下記のエラーがどうしても解決できません。
発生している問題・エラーメッセージ
Assets\script\Player.cs(3,26): error CS0234: The type or namespace name 'Eventing' does not exist in the namespace 'System.Diagnostics' (are you missing an assembly reference?)
該当のソースコード
c#
1using System.Collections;2using System.Collections.Generic;3using System.Diagnostics.Eventing.Reader;4using System.Security.Cryptography;5using System.Text.RegularExpressions;6using UnityEngine;7 8public class Player : MonoBehaviour 9{10 //インスペクターで設定する11 public float speed;//速度12 public float gravity;//重力13 public float jumpHight;//ジャンプ高度 14 public float jumpSpeed;//ジャンプ速度15 public float jumpLimitTime;16 public float stepOnRate;17 public GroundCheck ground;//設置判定18 public GroundCheck head; // 頭衝突判定19 public AnimationCurve dashCurve;20 public AnimationCurve jumpCurve;21 22 //プライべーと変数23 private Rigidbody2D rb = null;24 private Animator anim = null;25 private CapsuleCollider2D capcol = null;26 private bool isGround = false;27 private bool isJump = false;28 private bool isDown = false;29 private bool isHead = false;30 private bool isOtherJump = false;31 private float jumpPos = 0.0f;32 private float jumpTime = 0.0f;33 private float ohterJumpHeight = 0.0f; 34 private float dashTime = 0.0f;35 private float beforeKey = 0.0f;36 private string enemyTag = "Enemy";37 38 39 // Start is called before the first frame update40 void Start()41 {42 //コンポーネントのインスタンスを取得する43 anim = GetComponent<Animator>();44 rb = GetComponent<Rigidbody2D>();45 capcol = GetComponent<CapsuleCollider2D>;46 }47 48 // Update is called once per frame49 void FixedUpdate()50 {51 if (!isDown)52 {53 54 //設置判定を見る55 isGround = ground.IsGround();56 isHead = head.IsGround();57 58 //キー入力を確認59 float horizontalKey = Input.GetAxis("Horizontal");60 float verticalKey = Input.GetAxis("Vertical");61 62 float xSpeed = 0.0f;63 float ySpeed = -gravity;64 65 if (isGround)66 {67 if (verticalKey > 0)68 {69 ySpeed = jumpSpeed;70 jumpPos = transform.position.y;// ジャンプ高度71 isJump = true;72 jumpTime = 0.0f;73 UnityEngine.Debug.Log("設置判定、キー入力あり");74 }75 else76 {77 isJump = false;78 }79 }80 else if (isJump)81 {82 //上矢印キーが押されているか83 bool pushUpKey = verticalKey > 0;84 //現在の高さはジャンプ可能な高さか85 bool canHeight = jumpPos + jumpHight > transform.position.y;86 //ジャンプ時間が長すぎないか 87 bool canTime = jumpLimitTime > jumpTime;88 89 if (pushUpKey && canHeight && canTime && !isHead)90 {91 ySpeed = jumpSpeed;92 jumpTime += Time.deltaTime;93 }94 else95 {96 isJump = false;97 jumpTime = 0.0f;98 }99 }100 101 102 if (horizontalKey > 0)103 {104 transform.localScale = new Vector3(1, 1, 1);105 anim.SetBool("run", true);106 dashTime += Time.deltaTime;107 xSpeed = speed;108 }109 else if (horizontalKey < 0)110 {111 transform.localScale = new Vector3(-1, 1, 1);112 anim.SetBool("run", true);113 dashTime += Time.deltaTime;114 xSpeed = -speed;115 }116 else117 {118 anim.SetBool("run", false);119 dashTime = 0.0f;120 xSpeed = 0.0f;121 }122 123 //前回の入力からダッシュの反転を判断して速度を変える。124 if (horizontalKey > 0 && beforeKey < 0)125 {126 dashTime = 0.0f;127 }128 else if (horizontalKey < 0 && beforeKey > 0)129 {130 dashTime = 0.0f;131 }132 beforeKey = horizontalKey;133 134 //踏みつけジャンプ135 //現在の高さはジャンプ可能な高さか136 bool canHeight = jumpPos + otherjumpHight > transform.position.y;137 //ジャンプ時間が長すぎないか 138 bool canTime = jumpLimitTime > jumpTime;139 140 if (canHeight && canTime && !isHead)141 {142 ySpeed = jumpSpeed;143 jumpTime += Time.deltaTime;144 }145 else146 {147 otherjumpHight = false;148 jumpTime = 0.0f;149 }150 151 //アニメーションカーブを速度に適用152 xSpeed *= dashCurve.Evaluate(dashTime);153 154 rb.velocity = new Vector2(xSpeed, ySpeed);155 156 }157 else158 {159 rb.velocity = new Vector2(0, -gravity);160 }161 162 }163 164 private void OnCollisionEnter2D(Collision2D collision)165 {166 if (collision.collider.tag == enemyTag)167 {168 //踏みつけ判定になる高さ169 float stepOnHeight = (capcaol.size.y * (stepOnRate / 100f));170 171 //踏みつけ判定座標172 173 float judgePos = transform.position.y - (CaptureCollection.size.y / 2f) + stepOnHeight;174 175 foreach (ContactPoint2D p in collision.contacts)176 {177 if (p.position.y < judgePos) 178 {179 ObjecCollision o = collision.gameObject.GetComponent<ObjectCollision>();180 if (o! = null) 181 {182 isOtherJumpHeight = o.boundHeight;183 o.playerStepOn = true;184 jumpPod = transform.position.y;185 isOtherJump = true;186 isJump = false;187 jumpTime = 0.0f;188 }189 else 190 {191 UnityEngine.Debug.Log("Oobjectcollisonがついてねぇぞ!!!");192 }193 }194 else195 {196 //ダウンする197 UnityEngine.Debug.Log("敵接触判定あり");198 anim.Play("Player_down_animation");199 isDown = true;200 break;201 }202 203 }204 }205 }206}
unityのバージョン変更やpcやvsの再起動なども試しましたが、治りませんでした。。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
0 コメント