why this code doesnt work for jumping ?!(Raycasting)
I 've read the unity docs and videos about raycasting...but when i test it my self it works with unity3D (with sphere,....)only.another question is how can we access the hit tag in unity2D with for example RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up); ??and the third question is can we use Physics.raycast instead of Physics2D.raycast in 2D game?does it work correctly?
void Update () { RaycastHit2D hit= Physics2D.Raycast(transform.position, -Vector2.up, 1f, 0); if (hit.collider != null) { if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space)) { rigidbody.AddForce(vector * speed, Force$$anonymous$$ode2D.Impulse); } } the code of above question
Your answer
Follow this Question
Related Questions
I never get inside if (Physics.Raycast(ray, out hit,Mathf.Infinity, touchInputMask) 1 Answer
Raycast on Graphic with Custom Mesh, 1 Answer
Create a constantly recycling ground tile in unity 2d? 0 Answers
Project 2D (windows build) crash randomly Unity 5.6 + crash log 0 Answers
Player should turn in the direction the player is running. (2D Game) 0 Answers