x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Local multiplayer

Hello, I'm trying to make a local multiplayer game (2 players sharing the keyboard with split screnn). For the moment i'm trying to instanciate the 2 cars that the players will use. On the game mode i have done as you can see in the imagens.

alt text

alt text

Where i spawn the first car and set the type for p1 and possess it with the player controller index 0 and then spawn the second car but this time i create a new player controller and set the type for p2.

The function setType is used to set if it should use player1 controllers or player2 as you can see on the following code:

void ATheArenaPawn::setType(FString type) { this->type = type; }

void ATheArenaPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent) { // set up gameplay key bindings check(InputComponent); if (type == "p1"){ InputComponent->BindAxis("MoveForward", this, &ATheArenaPawn::MoveForward); InputComponent->BindAxis("MoveRight", this, &ATheArenaPawn::MoveRight); //InputComponent->BindAxis(LookUpBinding); //InputComponent->BindAxis(LookRightBinding);

     InputComponent->BindAction("Handbrake", IE_Pressed, this, &ATheArenaPawn::OnHandbrakePressed);
     InputComponent->BindAction("Handbrake", IE_Released, this, &ATheArenaPawn::OnHandbrakeReleased);
     InputComponent->BindAction("SwitchCamera", IE_Pressed, this, &ATheArenaPawn::OnToggleCamera);

     InputComponent->BindAction("ResetVR", IE_Pressed, this, &ATheArenaPawn::OnResetVR);
 }
 else{
     InputComponent->BindAxis("MoveForward_p2", this, &ATheArenaPawn::MoveForward);
     InputComponent->BindAxis("MoveRight_p2", this, &ATheArenaPawn::MoveRight);
     //InputComponent->BindAxis(LookUpBinding);
     //InputComponent->BindAxis(LookRightBinding);

     InputComponent->BindAction("Handbrake_p2", IE_Pressed, this, &ATheArenaPawn::OnHandbrakePressed);
     InputComponent->BindAction("Handbrake_p2", IE_Released, this, &ATheArenaPawn::OnHandbrakeReleased);
     InputComponent->BindAction("SwitchCamera_p2", IE_Pressed, this, &ATheArenaPawn::OnToggleCamera);

     InputComponent->BindAction("ResetVR_p2", IE_Pressed, this, &ATheArenaPawn::OnResetVR);
 }

}

When the possess method is called the SetupPlayerInputComponent is also called and using the type set before it checks if the instance is for the player1 or player2. I'm using the simple player controller that come with the project. The problem is that only the first car instantiated responde the commands.

Thanks for the help

Product Version: UE 4.7
Tags:
player1.jpg (64.2 kB)
player1.jpg (64.2 kB)
player2.jpg (69.3 kB)
more ▼

asked Jun 24 '15 at 02:59 AM in Using UE4

avatar image

Rohr
1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question