For key press normally we use Input, but I want to call a specific key press event without giving input from keyboard. In details I want a key press (space) event running with a Boolean value. But that key press event is not be called from keyboard input.
If (Input.GetKeyDown("space")) {
//space key is pressed
}
But I want:
If(press == true) { //here press is Boolean
//call space key is pressed event without key board input
}
You need to take advantage of a programming concept called subroutines. They are also called functions, or methods and possibly several other names.
Define a function that does whatever a spacebar press should do, then call it whenever you need that action performed. Functions are defined in C# usually as
< access modifier > < return value > < function name > (< parameters >){
< method body >
}
that means, for example
public void SpacePressed(){/*empty method*/}
and in UnityScript as
function < function name >(< parameters >)< : return value, optional >{
< method body >
}