- Home /
Make function take things like Object.transform.forward, Vector3.up as a variable?,Make a function take GameObject.transform.forward or something similar as a variable?
Want to allow controllers to access custom physics engine and move objects based on specified direction (Object.transform.forward, Vector3.up, etc).
void AddForce(Direction, float force)
{
Object.Move(Direction * force);
(using the character controller to stop fast objects from going through walls)
}
,I want to make a function like this that my controllers can use to move objects with my custom physics engine. (uses a small character controller in the centre of the object to stop it from going through objects).
void AddForce(Direction (vector3.up, GameObject.transform,forward), float Force)
{
Object.Move(Direction * Force * FixedTimeStep);
}
I set out the example code nicely but all indents and stuff went away. Here is a photo of function
also just realised my original question before i logged in was added onto the question when i rewrote it after i logged in first time asking question so and it I obviously failed
There's the 101 / 010 button in the editor controls which allows you to mark the selected text as code. I just formatted your code as code.
Answer by xxmariofer · Feb 26, 2019 at 10:31 AM
hello, the "Directions" are Vector3 like this
void AddForce(Vector3 direction, float Force)
{
// ..........Your stuff........
}
//calling the method
AddForce(transform.forward, 50.f);