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"

Change character collider

Hi

I'm working on a game using a player class deriving from the Character class. So i've the capsule component used by the mouvementComponent. As i'm already using the mouvement component, i'd like to keep it.

However i was wondering if the capsule component could be use only to move or jump and every other collisions would be done by the collider of the skeletal mesh (Hitbox or anything else) . Here is my problem, i didn't succeed to make the mesh collide with the ground (I'm using the mannequin from the demo project without changing anything)

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #pragma once
 
 #include "GameFramework/Character.h"
 #include "../Source/Rapiere/PrimitiveComponent/PC_PlayerWeapon.h"
 #include "C_Player.generated.h"
 
 UCLASS()
 class RAPIERE_API AC_Player : public ACharacter
 {
     GENERATED_BODY()
 
 public:
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, category=Gameplay)
     UAnimMontage* FireAnimation;
     bool fais1 = false;
 
     // Sets default values for this character's properties
     AC_Player();
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
 
     // Called every frame
     virtual void Tick(float DeltaSeconds) override;
 
     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
 
     void StopJump();
 
     void StartJump();
 protected:
     /**Represent the player's weapon and it's component*/
     UPROPERTY(EditAnywhere, Category = Weapon)
     UPC_PlayerWeapon* PC_Weapon;
 
     /**Set if the character is firing*/
     UPROPERTY(VisibleAnywhere, Category = AC_Player)
     bool BisFire = false;
 
     /**Main camera of the character*/
     UPROPERTY(EditAnywhere, Category = camera)
     UCameraComponent* FirstPersonCamera;
 
 
     /***/
     UPROPERTY(VisibleAnywhere, Category = camera)
     float BaseTurnRate;
 
     /***/
     UPROPERTY(VisibleAnywhere, Category = camera)
     float BaseLookupRate;
 
 
     /**Function called OnLeftClick Pressed to set BisFire to true*/
     void StartFire();
 
     /**Function called OnLeftClick Released to set BisFire to false*/
     void StopFire();
 
     /**Function called for zs axis*/
     void MoveForward(float value);
 
     /**Function called for qd axis*/
     void MoveLeftRight(float value);
 
     /***/
     void TurnAtRate(float Rate);
     /***/
     void LookUpAtRate(float Rate);
 };
 


And here is the cpp file, i've let the constructor and the tick function to reduce the amont of code. Just ask me for more.

 #include "Rapiere.h"
 #include "C_Player.h"
 
 
 // Sets default values
 AC_Player::AC_Player()
 {
     // Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
     // Create a mesh component that will be used when being viewed from a '1st person' view (when controlling this pawn)
     BaseTurnRate = 45.f;
     BaseLookupRate=45.f;
     //To do in the editor
     static ConstructorHelpers::FObjectFinder<USkeletalMesh> SkeletalMeshTower(TEXT("SkeletalMesh'/Game/Mannequin/Character/Mesh/SK_Mannequin.SK_Mannequin'"));
     if (SkeletalMeshTower.Object) {
         GetMesh()->SetSkeletalMesh(SkeletalMeshTower.Object);
     }
     //Setup Mesh with mesh coming from Editor
     if(GetMesh()!=NULL){
         GetMesh()->SetOnlyOwnerSee(true);
         GetMesh()->bCastDynamicShadow = false;
         GetMesh()->CastShadow = false;
         GetMesh()->AttachToComponent(GetCapsuleComponent(),FAttachmentTransformRules::KeepRelativeTransform);
         
         //Setup Camera attaching it to head socket
         FirstPersonCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FPSCamera"));
         FirstPersonCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules::KeepRelativeTransform,TEXT("sock_head"));
         FirstPersonCamera->bUsePawnControlRotation = true;
         
         //Setup weapon to hand Socket
         PC_Weapon = CreateDefaultSubobject<UPC_PlayerWeapon>(TEXT("Weapon"));
         PC_Weapon->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale,TEXT("sock_hand_r"));
     }
     
     AutoPossessPlayer = EAutoReceiveInput::Player0;
     GetCharacterMovement()->AirControl = 1;
 }
 
 // Called when the game starts or when spawned
 void AC_Player::BeginPlay()
 {
     Super::BeginPlay();
     
 }
 
 // Called every frame
 void AC_Player::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
     if (BisFire&&!fais1)
     {    
         PC_Weapon->Fire();
         fais1 = true;
     }
 }
 
   
 
 

Here are the entire code of C_Player. But if you need more information about skeletalmesh or anything else to help me, don't hesitate. Thanks for your help

Product Version: UE 4.12
Tags:
more ▼

asked Jul 24 '16 at 02:53 PM in C++ Programming

avatar image

Zetfire
5 4 6 8

(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