Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Overriding BP Value #344

Open
mix-spice opened this issue Jun 13, 2024 · 0 comments
Open

Issue with Overriding BP Value #344

mix-spice opened this issue Jun 13, 2024 · 0 comments

Comments

@mix-spice
Copy link

Hey guys, so I have created the Stop() function that works fine and I am trying to change a value of throttleInput that I have in this function. The function is made via BP(see a photo)
Screenshot 2024-06-13 185253

The issue lies in my unrel.js code, that just doesnt change that value. I dont know where the issue is, I've tried different ways around and it still doesnt see to work for me. Below I'll paste a code that I wrote, maybe someone could be kind to check it out and help me figure out where the issue lies? Thanks in advance!

"use strict";

const SportAIBlueprint = Blueprint.Load('/Game/VehicleTemplate/Blueprints/SportsCar/Sport_AI').GeneratedClass;

// Define a class extending the loaded Blueprint
class Sport_AI extends SportAIBlueprint {
properties() {
this.VehicleMovementComponent;
this.Stand;
}

Stop() {
    console.log("Overridden Stop function called");

    // Get the Vehicle Movement Component
    let vehicleMovementComponent = this.VehicleMovementComponent;

    if (vehicleMovementComponent) {
        // Set Throttle Input to the desired value
        vehicleMovementComponent.SetThrottleInput(-1.0);
        
        // Optionally, set Handbrake Input
        vehicleMovementComponent.SetHandbrakeInput(true);

        // Update any other necessary properties
        this.Stand = true;

        console.log("Throttle input set to -40.0 and handbrake applied.");
    } else {
        console.error("VehicleMovementComponent not found.");
    }
}

}

// Compile the Sport_AI class
let SportAI_C = require('uclass')()(global,Sport_AI);

function getFirstSportAIInstance() {
let instances = GWorld.GetAllActorsOfClass(SportAI_C).OutActors[0];
return instances.length > 0 ? instances[0] : null;
}

const Sport_AIActorBP = '/Game/VehicleTemplate/Blueprints/SportsCar/Sport_AI.Sport_AI_C';
let Sport_AIActor = GWorld.GetAllActorsOfClass(Sport_AIActorBP).OutActors;
let Sport_AI_instance = Sport_AIActor.length > 0 ? Sport_AIActor[0] : null;

function main() {
let car = getFirstSportAIInstance();
if (car && car.Stop) {
car.Stop();
} else if (!car) {
console.error("No instances of Sport_AI found.");
} else {
console.error("Stop method not found on instance:", car);
}
}

main();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant