Understanding the basics, but now how do I apply it?


#1

Hey guys,

So I’ve gone through the examples in the IDE and a number of the starting tutorials around here, but now I want to get my feet wet and at the very least try to replicate functionality of things I can do in blueprints and C++, but I’m unfamiliar with how Skookum exactly hooks into it all.

Let’s take for example trying to ray cast from the camera. I was having trouble grabbing the world location and forward vector of the camera. If I can’t even do that easily, I’m not sure I’m going to be able to use Skookum effectively.

I’m also having trouble looking through the documentation, so if there’s something I’m missing I’d appreciate being pointed in the right direction.


#2

It sounds like you are mostly trying to figure out the UE4 commands that you want.

Here is a mechanism for searching in SkookumScript:

If you know the answer in BP or C++ that would help us.

Otherwise we can look up the answer on your behalf.


#3

Thanks for replying!

I haven’t considered using an external ide, but I’ll give it a shot.

FHitResult HitResult = FHitResult();
FVector StartTrace = FirstPersonCameraComponent->GetComponentLocation();
FVector ForwardVector = FirstPersonCameraComponent->GetForwardVector();
FVector EndTrace = (ForwardVector * 5000.f) + StartTrace;
FCollisionQueryParams CQP = FCollisionQueryParams();

if (GetWorld()->LineTraceSingleByChannel(HitResult, StartTrace, EndTrace, ECC_Visibility, CQP))
{

    DrawDebugLine(GetWorld(), StartTrace, EndTrace, FColor(255, 0, 0), true);

    if (HitResult.GetActor() != NULL)
    {

        HitResult.GetActor()->Destroy();

    }

}

That’s one piece of code I’d like to get working. I was using it within the class of the player character.

This is a really messy set of blueprints, but it would be nice to know where to start with breaking that down into Skookum. I understand if it’s a bit much to sort through though, sorry!


#4

It’s difficult to see what exact nodes you’re using in that screenshot as the image is too low res but I can see some vector related nodes. A lot of this geometry and math related processing can be done much more elegantly in Skookum.

Check out our :ue4: to :sk: example project for a 1-to-1 comparison:

You can download the project and see how the controls are translated from BP to Skookum.

Also remember that you can create BP nodes using SkookumScripts so you can convert any set of nodes in your example to Skookum and then call it in your graph. Check out basic tutorial #3 for this:


#5

Thank you, though I did review these already. The bigger concern here is dealing with the camera. In the fps template, they have a first person camera component that I’m having a lot of trouble using correct syntax to find it in the scene to get the location and forward vector.

The node example in question isn’t difficult to work out math wise, but there are a couple things like getting the enum state of the character to check if they’re walking etc, and also how to grab the capsule component (I think that’s what I did?) to set the velocity before launching.

I think the big trouble I’m having here is dealing with components.


#6

You might find it helpful to look at the :sk: browser for the class that you’re deriving from. For instance the Character class:

So if you’re writing :sk: code in your character derived class you can get the capsule component using @capsule_component similarly the movement component is @character_movement. Generally every variable and component of UCharacter is auto-generated and can be seen in the :sk: browser.

Regarding camera and finding it in the scene, it depends on how you have your game and camera setup. I’m not sure what the FPS template does, but I’m assuming there’s some Pawn with a camera component that’s part of their blueprint? If so, you can just add a Skookum Data Component to the pawn and then on the :sk: side just reference the camera component (again looking in :sk: browser for the BP will show you the same component names that you see in the BP hierarchy only with underscores instead of spaces and all lowercase).

Once you have access to the camera component, you can get the forward vector using @my_component.forward_vector (assuming that @my_component is your camera components name… this function is provided by SceneComponent fyi). Similarly forward vector of an actor is some_actor.actor_forward_vector.

Things can be a bit confusing at first, hopefully some of this helps.