Download

Getting confused by really basic principle of scripting

Can someone please help me understand, in terms of a standard FPS where you interact with the environment, where are most of the instructions going to? Initially I was putting instructions (nodes etc) into the blue print of an interactive object. Going back to an old tutorial I’ve noticed the teacher is putting it into his character blueprint. I suppose it makes sense right? If you get a key and create a bool variable saying that you have the key you want that bool to always be available to call from anywhere in the game. Because you can’t call upon a variable from another blueprint?

So if I mostly do instructions in MyCharacter blueprint then I need to drag that blue print into the scene? If I don’t have a playerstart icon I just fall through the world and have other oddities. SO, is the idea that you have playerstart where you want to spawn and then just have BP_MyCharacter hidden away in your level? Then you do the usual project setting stuff telling the game to use BP_Mycharacter as a sort of ‘template’ for the playerstart?

You might want to have a look at the introduction to blueprints and third person blueprint tutorials.

These videos are incredibly well designed and will give you a solid base to start with.

Thanks. The first one I tried when I started using Unreal, it’s a bit out of date and confusing as mentioned in the comments of episode 2. Someone has recently mentioned that if you watch episode 7 you’ll have the knowledge to create what is missing in episode 2. So I’ll give it another go now that I’ve learnt more (Gone through about 8 hours worth of tutorials on digital tutor tutorials). The second video is more for animation, I’ve gone through it all this morning. Nothing in it helps with my current problem but it’s full of interesting stuff to know.

Your GameMode dictates what your PlayerPawn or character will be. PlayerStart dictates where in your level your pawn will spawn when the game starts, so you don’t bring the character into the scene yourself. You can set your game mode in World Settings. You may need to create a new BP that derives from GameMode if you haven’t already.

Then open up the GameMode and go to Defaults and set your character as the default pawn.

You can put interaction logic wherever you want. Some people put it on the character, some on the object you’re interacting with, some on the level blueprint, some go with other options. I recommend you put it on the player controller. This way if you change characters at any point, all of your logic still works. As long as you’re still using the same PlayerController. That’s the reason the class exists. If you don’t plan on the character changing at any point, you can put all that logic on the pawn if you want.

The way I do it is I have the PlayerController handle the input and then translate it into a custom event on the pawn that actually performs the action. For example, the PlayerController listens for right joystick motion. Then it checks to see if “isCameraControllable” (a custom boolean variable) is true, then it multiplies the input by the custom sensitivity float variable and passes that to a custom event on the character. Then the character will add Yaw Input to the camera every time it’s fired.

This will also allow you to write artificial intelligence for your character. The AI will send custom events to the character based on different logic, but the end result on the character will be the same.

This same principle applies to objects in the world as well. Just have the PC or the object check for overlap between the two, then fire an event off in the object when a key is pressed.

Thanks Jared, it’s all a lot to take in but it’s slowly making sense. I suppose the primary thing throwing me off here is a bit in a tutorial where they have you pick up a pickaxe. Then they create a bool that’s basically telling the computer that the character has that pickaxe. Then they go back to the main edit screen and in the object properties in the top right there is a BP_MyCharacter. So he 100% has a BP character in the scene as well as a playerstart. He then selects BP_MyCharacter in that top right screen and now in the properties there is a default>pickaxe enabled? with a tick box. So he can basically play/simulate the game and he can see when his character has the pickaxe because as soon as he takes it that tick box is enabled. With only a playerstart in the scene, I am not able to see that default>pickaxe.

So, I don’t quite understand when you say that I don’t need to bring my character (BP_MyCharacter) into the scene? Whatever you’re doing though, it sounds good as I do indeed plan on switching characters.

You absolutely can bring in your character if you’d like, but I personally have had nothing but problems doing that. Was he doing this while playing the game? Because you can play in editor using the main window and Shift+F1 to free your mouse then go to your scene outliner and find your character there and see all the stuff like defaults and whatever. This is while the game is still playing. After you hit stop, the pawn is destroyed.

In my experience, bringing your pawn into the scene will result in your pawn existing twice - once as a brainless object and once as your controlled object. I’m sure there’s a way to set your PC to auto-possess a placed pawn instead of spawning its own but I’m not 100% on the logistics of that.

Ah yes, I looked back at the tutorial and that’s what is going on. He’s doing the Shift+F1 thing when looking at the properties of his character. Good to know!