Unity2d shooting while running [closed] - unity3d

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
When I shoot a projectile while running the projectile collides with the player, i.e. the player's collider is hitting the bullet's collider.
What is the best way to prevent this? By making a space between the gun and the projectile to avoid collision?

There are 2 ways I can think of right now.
1- You can create a selective collision script (or edit your existing one) and add an exception for the player object. So, bullets can go through the player. This is the main way to go.
2- You can use layers (or Z depth) and you can create a whole layer for bullet spawner etc. And make enemies also have targets in that layer/depth.
I don't have Unity installed on my current system right now. But I will install it when I get a chance, and if you don't solve it until then I will try to help properly.

Related

Instantiating objects at a random position along the x axis [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I am making a game where red bullets are coming down on the screen at you, and I have the instantiating part done, but I can't figure out how to make them spawn at a random spot along the top of the screen. I am using Unity.
What you could use is the built in unity function of Random.Range(minValue, maxValue) and than where you spawn the prefab you assign a variable using Random.Range as the x location. Example from Unity Offical API

How to setup a minimap in multiplayer games? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I wanted to setup a minimap for my multiplayer game. I am using photon for multiplayer.
Thanks in advance
This question is probably too vague, but the rough strokes of how I would do it would be as follows
Render you scene (or only your environment) from a top down orthographic camera
Write a shader that transforms your player's positions to this camera's screenspace and draws a marker at their position (this can be quite difficult)
Render this out to a texture and display it on a mesh at the top of your screen / UI
This is not something that is super easy to do, you might be better just looking for one on the asset store.
If you have any difficulties then maybe ask another question specifically focusing on the area you're struggling with
best of luck

Why is my player falling through the floor? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have just created a repository on Github with my project.
The problem I having is my player falls right through the floor. If I import Standard Assets and use theis first person character, This does not happen. I am assuming it is an issue of using vectors, but I do not know.
Identify Issue
It mostly happen when there is cno collider attached to the body but you try to
apply gravity to gameobject . The gameobject tries to move towards down due to the gravity but the collision helps that object to sustain on its place .
Apply any of below solutions
Remove the gravity applied on the body
Attach the Collider that help the gameobject stopping it from falling it down
Check the x y and z axis as well. Click on the gameObject it will tell you its axis . Adjust your axis according to the logic you have applied

Allow colliders with rigidbodies to intersect each other [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am making a car game. My cars are colliding, but I don't want the cars to collide - I want the cars to go inside of the other cars, which have both a rigidbody and a collider. Is there a way to allow my cars' colliders to ignore each other for physics interactions?
Go to project settings, physics and take a look on the matrix.
With this matrix you can exclude cars colliding with each other giving them proper layer and unchecking this layer to colide with itself.

Why Isn't My 2D Box Collider Working? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
i'm making boundaries for the characters in my 2d game in unity 5. I added box colliders to the borders and my characters but the characters don't stop when they run into the other borders.
I don't have much experience of Unity 5, but probably these things work similarly than with old versions of Unity.
Colliders can be used for stopping things to go inside each other without writing your own OnCollisionEnter function.
So there must be some other problem. Check that:
Colliders are same type. 2D and 3D colliders don't detect collisions with each other.
At least one participant of the collision needs to have rigidbody component attached.
Check that is trigger is not selected on any of the colliders
Pause the game and check in the scene view that the green boxes of the colliders actually colliding
Check the layers of the gameobjects and check if they are should collide because of the layer based collision
When the colliders intersect it will trigger an OnCollisionEnter event. You need to tell it what to do after that. It could be setting the velocity to 0 in the case of a ball hitting the wall, or it could be awakening enemies in the case of a player walking into a trap. You have to define the behavior.