Editable Attributes (1)

Slides:



Advertisements
Similar presentations
Messiaen Quartet for the end of time And another.
Advertisements

Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 2: Using Methods.
Sub Programs To Solve a Problem, First Make It Simpler.
Alice Variables Pepper. Set to Java look Edit / preferences restart.
Binary Arithmetic Math For Computers.
4 Things that affect your pictures… ISO Aperture Shutter Speed LIGHT.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
1 Day 3 Directories Files Moving & Copying. 2 Case Sensitive First thing to learn about UNIX is that everything is case sensitive. Thus the files: –enda.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Nachos Phase 1 Code -Hints and Comments
1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute.
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
Iteration. Adding CDs to Vic Stack In many of the programs you write, you would like to have a CD on the stack before the program runs. To do this, you.
Module 10: Simple Inheritance #1 2000/01Scientific Computing in OOCourse code 3C59 Module 10: Simple Inheritance In this module we will cover Inheritance.
3–D Helium Molecule Tutorial Alice Project Duke University Professor Susan H. Rodger Gaetjens Lezin June 2008.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Moving Around in Scratch The Basics… -You do want to have Scratch open as you will be creating a program. -Follow the instructions and if you have questions.
Playing Music in Alice By David Yan Under the direction of Professor Susan Rodger July 2015.
 To begin you first need to sign up to Weebly by going to or alternatively and we will create an account.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
How to use By Lauren Fowler. Adding Attachments Attachments are pictures, videos and files that you have on your computer. You can add these to.
Sega 500 Scripted events and Sequences Jeff “Ezeikeil” Giles
Rebecca Gibson EDIT 5027 Fall About Engrade Engrade is a free digital gradebook application available to anyone. Let me say that again FREE! Some.
Introduction To Greenfoot
An Introduction to Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University, June 2009 Updated June 2014 by Ellen Yuan.
SQL SERVER 2008 Installation Guide A Step by Step Guide Prepared by Hassan Tariq.
1 Introduction to Object Oriented Programming Chapter 10.
Module 7: Constructors #1 2000/2001Scientific Computing in OOCourse code 3C59 Module 7: Constructors and Destructors: In this module we will cover: Constructors.
Illuminating Computer Science CCIT 4-6Sep
Boat Racing Game Challenge #3 By Chris Brown Under the direction of Professor Susan Rodger Duke University, January 2013 Based off of the Boat Racing Game.
Introduction to Arrays. Learning Objectives By the end of this lecture, you should be able to: – Understand what an array is – Know how to create an array.
PaintPictureBoxDemo Refers to the PaintPictureBoxDemo Visual Basic Program Included With The Lecture.
Module 9: Operator overloading #1 2000/01Scientific Computing in OOCourse code 3C59 Module 9: Operator Overloading In this module we will cover Overloading.
EEC-693/793 Applied Computer Vision with Depth Cameras
Chapter 4 - Finishing the Crab Game
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
An Introduction to Alice (Short Version)
EEC-693/793 Applied Computer Vision with Depth Cameras
Introduction to Python
Loops BIS1523 – Lecture 10.
Eclipse Navigation & Usage.
RAD Certification Checkpoint #2 Introducing RadStudio (Hello World)
Chapter 5 Conclusion CIS 61.
Introduction to Events
EEC-693/793 Applied Computer Vision with Depth Cameras
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Microsoft Word Reviewing Documents.
Java LESSON 7 Objects, Part 1
Unit 7 – Excel Graphs.
Unreal Engine and C++ We’re finally at a point where we can start working in C++ with Unreal Engine To get everything set up for this properly, we’re going.
OOP Paradigms There are four main aspects of Object-Orientated Programming Inheritance Polymorphism Abstraction Encapsulation We’ve seen Encapsulation.
Child Actor Component Templates
UNITY TEAM PROJECT TOPICS: [1]. Unity Collaborate
Theory of Computation Turing Machines.
Alice Variables Pepper.
CIS 488/588 Bruce R. Maxim UM-Dearborn
We’re slowly working our way towards classes and objects
Unit 11 – PowerPoint Interaction
Coding Concepts (Basics)
Introduction to TouchDevelop
Fundamentals of Data Representation
How to Run a Java Program
An Introduction to Alice
EEC-693/793 Applied Computer Vision with Depth Cameras
Visibilities and Static-ness
SPL – PS2 C++ Memory Handling.
Presentation transcript:

Editable Attributes (1) Whenever we add an object to the scene (whether that’s an Actor or a Pawn) We can edit its properties in the Details Panel When we made variables in a C++ class before, they were only accessible in the C++ class itself

Editable Attributes (1) However, we can change that We can make these variables visible in the Unreal Engine Editor There are two places we can make a variable visible In a Blueprint In the Details Panel We can do one, the other, or both

Editable Attributes (1) To test this out, we’re going to make a C++ class in a C++ Unreal Engine project This C++ class will represent a MovingPlatform We’re going to give it points to move between in the editor

Editable Attributes (1) The first thing we need to do is get our class set up with attributes One for the location to move to Another for the duration of its movement The idea is that this platform will move between this location and its starting position With speed based on the duration we’ve given it

Editable Attributes (1) We’ll make the two variables here The location is a FVector Which stores the X, Y, and Z components of the location

Editable Attributes (1) However, just adding these variables isn’t enough We need to flag to Unreal Engine that these variables are usable in the editor That’s done using macros

Editable Attributes (1) Macros are small function-like bits of code we can use literally whenever we want Usually above a variable, function, or class Different macros will do different things Unreal has a bunch of them we can use

Editable Attributes (1) We’ve already seen one of them GENERATED_BODY() Which makes the class usable in Unreal Engine We need to use another if we want to use these variables in Unreal Engine

Editable Attributes (1) The one we’re using is UPROPERTY We put these above the variables we want to include in the editor UPROPERTY macros have quite a few arguments we can include in them Which change how Unreal Engine uses this variable

Editable Attributes (1) The following arguments can be added to the UPROPERTY macro (to change how Unreal Engine uses it) EditAnywhere: the attribute can be viewed and changed in the Details Panel EditDefaultsOnly: we can change the attribute in the Details Panel, but only before running the scene VisibleAnywhere: like EditAnywhere, but we can’t change its value BlueprintReadOnly: can be used in a Blueprint, but not written to BlueprintReadWrite: can both read and write to the attribute in a Blueprint Category: used to put the attribute in a specific category in the Details Panel

Editable Attributes (1) We’ll stick with one mixture of these for all our attributes This means we can edit it both in the Blueprint and the Details Panel Under the menu “Menu Name” We’ll change that depending on the attribute UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “Menu Name”)

Editable Attributes (1) Let’s add that macro above both of the variables we made

Editable Attributes (1) Then we’ll compile the C++ class And make a Blueprint for it

Editable Attributes (1) When we add this Actor to the scene and select it We’ll see those variables in the Editor!

Editable Attributes (1) Ex Make a new Empty C++ Unreal Engine project Create a C++ class called MovingPlatform Give it two variables: the location to move to (FVector), and the duration of the move (float) Add the UPROPERTY macro above both variables so that It can be edited anywhere Can be read from and written to in a Blueprint They are put in the category “Platform Setup” Compile your C++ file and make a Blueprint inheriting from it Add one to the scene Make sure you can edit those two variables

Editable Attributes (2) We can give these values default values if we wanted to Those values will appear in the Details Panel Until we change them to different values We do that from the constructor

Editable Attributes (2) In the constructor we can set the value for the duration Can’t do location As we don’t know where this Actor is in 3D space before it’s been added to the scene

Editable Attributes (2) When we compile this and add another of these Actors to the scene Its duration is now the default value we gave it

Editable Attributes (2) Ex Give the Actor a default duration in its C++ constructor Compile the C++ code and add another Actor to the scene Make sure its duration is the same as the default you set in the constructor

Making the Platform Move (1) With the attributes set up, let’s look into making the platform move We’re going to make the platform move only to the destination for now We’ll make it move back again afterwards

Making the Platform Move (1) For this, we need to store its starting position somewhere We’ll make a variable for it Then we’ll set it in the BeginPlay function As we know at that point where the Actor is Then we’ll use the duration to work out how much to move between the start and end location every Tick

Making the Platform Move (1) Let’s add that variable first We don’t need to make this a UPROPERTY As only the C++ file will use it We’ll also add a variable for the current movement time

Making the Platform Move (1) Then, in the BeginPlay function, we’ll give this a value Specifically, the current location of the Actor And we’ll set the current movement time to 0

Making the Platform Move (1) Ex Add two private variables to your C++ class One for the starting location (FVector) One for the current movement time (float) In BeginPlay, give the starting location the current location of the Actor And set the current movement time to 0

Making the Platform Move (2) There are a few ways we could make our platform move For example, we could calculate the distance between the two points Along each of the axes Then calculate the speed based off the duration

Making the Platform Move (2) However, Unreal Engine can take a lot of the trouble off our hands By using the Lerp unction Lerp stands for Linear Interpolation It lets us change a value, between two values, over a period of time

Making the Platform Move (2) So, we could Lerp between the start position and the end position Imagine these positions as 0 and 1 Lerp takes a third value – an alpha – to work out what value to return between these two points

Making the Platform Move (2) Imagine our positions were 10 and 20 An alpha of 0 would return 10, and an alpha of 1 would return 20 Any alpha in between would return a value between them So 0.5 would return 15

Making the Platform Move (2) So we know what the two values for the start and end will be But what about the alpha? That’s where the duration and current movement time come in If we divide the current movement time by the duration, we’ll get a value ranging from 0 to 1 Lerp doesn’t care about going over 1

Making the Platform Move (2) Let’s use this FMath::Lerp function in Tick Where we’ll give it the three needed values First the starting position Then the end position Then the current movement time divided by the duration

Making the Platform Move (2) This isn’t going to do anything unless we increase the current movement time So we’ll add the delta time to it

Making the Platform Move (2) That’s all we need to do! Let’s compile this and give the Actor a position to move to

Making the Platform Move (2) When we run the game, we’ll see the platform move!

Making the Platform Move (2) Ex In the Tick function of the C++ class, use the FMath::Lerp function to return a value Use the starting location as the first argument Use the end location as the second argument Use the current movement time divided by the duration as the third argument Set the Actor’s World Location to the value returned by the Lerp Then increase the current movement time by the delta time Compile your C++ class and run your game You could see the Actor move!

EXTRA: Make the Platform Move Back Can you think of a way of making the platform move back when it reaches the end? Feel free to add as many variables as needed for this Here’s a hint: Lerp works forwards and backwards

EXTRA: Make the Platform Cycle Now that it moves backwards, can you make the platform cycle back and forth You’ll need to make only a few more adjustments to get this working OPTIONAL: Once this is done, can you add the number of times the platform cycles as an editable attribute?

END OF UNIT!