cegepmatane / projet-specialise-2022-ManoelNohra

projet-specialise-2022-ManoelNohra created by GitHub Classroom
0 stars 0 forks source link

Le joueur peut utiliser un grappin qui l'attira au point de collision #14

Open Chopv1 opened 2 years ago

Chopv1 commented 2 years ago

Le personne peut tirer un grappin, qui, une fois une collision atteinte, approchera le joueur à l'endroit de la collision, s'il n'y pas de collision le joueur n'est pas déplacer :

Chopv1 commented 2 years ago

J'ai suivi ce tutoriel en adaptant avec ce que j'avais déjà fait pour le grappin : https://www.youtube.com/watch?v=Mu4oJvirSGc&t=322s Voici le code en C++ que j'ai utilisé et fait avant de suivre le vidéo :

void APerso::Hook()
{
    if (h != nullptr)
    {
        h->Destroy();
    }
    if (World != NULL && !isHooking)
    {
        SpawnRotation = GetControlRotation();

        SpawnLocation = ((MuzzleLocation != nullptr) ?
            MuzzleLocation->GetComponentLocation() :
            GetActorLocation()) + SpawnRotation.RotateVector(GunOffset);
        FActorSpawnParameters ActorSpawnParams;
        ActorSpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding;
        h = World->SpawnActor<AHook>(hook, SpawnLocation, SpawnRotation, ActorSpawnParams);
        isHooking = true;
    }
    else
    {
        if (&h != NULL)
        {
            h->Destroy();
        }
        isHooking = false;
    }
}

Le blueprint du grappin permettant de la set up de la mécanique ce qui amorce tout situé dans bp_hook : image

Le blueprint du personnage nécessaire pour le faire mouvoir lorsque le script au dessus s'enclanche et le cancel du grappin à tout moment : image