This is not really a solution to your problem, but rather an explanation of how you need to approach the solution. I’d suggest you read this, and then find a guide for handling overlaps / collisions in UE4. There’s a lot to understand so take it easy. Repetition is key.
The basic foundation of OOP is classes and objects pretty much. Classes and Objects are connected, but not the same.
To put it simply. A Class is the instruction on how to create Objects. Basically, the class is the mould, and the object is the result of the mould. An object is an instance of a class.
So, AThirdPersonCharacter is your Class. When you want to create an actual AThirdPersonCharacter, the engine runs through the Constructor in your class and creates an Object. In C++ a constructor looks like “ClassName::ClassName”. You can create as many objects as you’d like from the same class, all containing the same properties and functions. After an object is created, you can modify it without modifying other objects of the same class.
In OOP, there are certain types of properties and functions marked as ‘static’. Static properties and functions do not modify a specific object, but the class directly.
AThirdPersonCharacter::CanDash = true;
This is a static call. You are referring to the class directly and not an object. Static properties are used when we want to change something on the class. This is rare.
What you want is to change something on the object.
ThirdPersonChar.CanDash = true;
This is a call on a specific object, so this is “correct” in that sense.
However, the first line creates a new object of type AThirdPersonCharacter. Then it changes CanDash on that newly created object. It does not reference an already existing object in the world, which is likely what you want to change.
You need to somehow get a reference to the object you want to change. How you do this will depend on what class is attempting to change the object.
If you simply want to change CanDash to true in your object, you just write “CanDash = true;” and it will change CanDash for the object itself.
If you set CanDash from the object you collide with, you need to retrieve the colliding character in the object and reference that.
Imagine the life of your Collision Actor. What does this actor need to know? Well it doesn’t need to know about a whole lot when it’s just standing there. It needs to know about itself, that it is in a world (your map), if it’s being possessed by an AI or Player and that’s basically it. It has no idea if there are other actors or objects in the world, since it doesn’t matter to it.
Suddenly another actor collides with it. Now it needs to know about this other actor that collided with it, so this triggers an event with details about the object that hit it. What hit me? Was it a sword, a bullet, another person? You can use this event, to change CanDash on the actor that collided with it.
Can’t remember what the exact name of the functions are, but every actor has a collision box, and when this collision box detects a collision, it will trigger an event, which runs some code. This event will contain information about who the actor collided with, and this will be the character you want to change CanDash on.
Hope this is of some help to you