How to change the turn of a player in an online multiplayer game in Unity [closed] - networking

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 6 years ago.
Improve this question
I'm new in Unity and I'm trying to create an online multiplayer game. This game is a tanks fight. The tank is prefab and it's called to be created twice. When you press the Space keyCode the tank shoots a bullet. I have all the network connections done but now I want to control the players turn. For example, if localPlayer shoots one time this would have to be the turn of the second player and so on.
Can anyone help me please?

How about having a common variable which updates after each turn. depending on the value of the variable you can determine who has the turn. you have to define the order which they take turns before starting the game.
Assume you have n players, and a common int value x which increases by 1 after each turn.
if( x%n == turn && Input.GetKeyDown(KeyCode.Space))
shoot();
players will not be able to shoot unless it's their turn. use a simple RPC function to update x from clients after each turn.

Related

How to make high score based on collected coins? [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 2 years ago.
Improve this question
I’m creating small 2d platformer on Unity. The core is that you have 30 sec to spend on a level + plus an enemy chasing you. You have to act fast and aggressive to get those coins. So, actually how to make the score go up after I touch a coin? And how to make it disappear after that? I thought I could make a trigger, but I want the coin to be driven by physics, because it looks cool when it falls from midair on the ground.
insert this sample on your coins and add Coillder + trigger it
private void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "yourplayertag"){
PlayerPrefs.SetInt("yourCoin", PlayerPrefs.GetInt("yourCoin") + 1); // if your coins stored in playerprefs
Destroy(gameObject);
}
}
and advice, you need to learn more about unity and this is not here on Stack, your question is very basic, do some research first and try many times, tutorials and unity manual will help

Obtaining encoder data [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 6 years ago.
Improve this question
Hello and in advance thank you for reading my post,
I am working on a project which is controlled by a stepper motor which also includes an encoder. I have made the motor running and now I want to proceed to the next step and include the functions of the encoder. I know that the encoder tells me the actual position travelled by the motor, however, as I am still quite a newbie, I have unfortunately no idea how to include the information of my encoder into my code (which library? which variables). Both motor and encoder are connected to my Arduino Uno and I have also attached a photo with the corresponding pins for the encoder.
Thank you for any much required help
Here's a huge list of resources and libraries, that should get you started: http://playground.arduino.cc/Main/RotaryEncoders
I'd recommend using this library as it automatically takes advantage of the interrupt capabilities, if you connect the encoder to the correct pins (2 & 3 on the Uno). You might need this in order to still get precise measurements even at high rpm.

How to implement a gamification system in ASP.NET Web Application [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 7 years ago.
Improve this question
I'm building a Web Application using ASP.NET MVC and I'd like to implement a Gamification system to make the user experience more exciting.
I'd like to start with a simple score for each user and as they progress and get more points they get badges and unlock new features for themselves, something similar to how Stackoverflow does it.
What appears challenging to me is how to check in the entire application, whether a user has reached a score that can recieve a badge. I don't want to duplicate my code and perform this check in every place that I'm incrementing a user's score.
I'd like to know how can I start implementing such a system. I know it's a broad question but I'm just looking for some starting ground and some good practice to begin.

what does the term rep-invariant and rep ok means? [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 6 years ago.
Improve this question
I heard this a lot when talking about software engineering and abstract data types, what does this do? Can anyone give me a concrete example of this concept?
A representation invariant is a condition concerning the state of an object. The condition can always be assumed to be true for a given object, and operations are required not to violate it.
In a Deck class, a representation invariant might be that there are always 52 Cards in the deck. A shuffle() operation is thus guaranteed not to drop any cards on the floor. Which in turn means that someone calling shuffle(), or indeed any other operation, does not need to check the number of cards before and after: they are guaranteed that it will always be 52.

How to write a program that controls a motor [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 1 year ago.
Improve this question
Connecting a motor to move a laser pointer up/down left/right to draw patterns.
Has anyone seen any examples to help the project? What programming language would be used for this? What computer ports would this use? Does a custom circuit have to be made or does a store exist for this?
There is a lot of different approaches you could go to this. Here is a few off the top of my head.
1. You could use a micro controller like an Arduino.
2. You could use a serial port and a socket. Here would be a good resource if you want to pursue this route. http://www.easysw.com/~mike/serial/serial.html
3. If you only need to control two motors you could use the headphone jack on your computer. You could hook a simple amplifier circuit up to each of the left and right speaker line. Then hook each of the amplifiers up to a separate motor. Then you could write a program that generates a separate sound for each channel, thus modifying the voltage given to each motor.
P.S if you use a servo, you can control the exact angle of the laser.

Resources