Ok, I’m working on an easy game where I have literally planned to have Mario-style actions. Only because they’re very simple mechanics and there really isn’t much to the game (why make a super FPS with explosions when I’m doing a simple Platformer? For example). Below are ideas of what I’m looking for, for scripts. If you’ve done the script like this before, that would be awesome! If not, I’m hoping on some tips in order to do it (I do know coding… I’m just not good at it)
Whenever my character hops on an enemy, my character doesn’t take damage, but the enemy does
— I have a piece of script in my 3rdPSWalker that says that whenever I touch an enemy, I’ll take damage, I’ll also bounce in the opposite direction that I touched the enemy—
===—I know how to do this to a point, I did something similar with my reasonably simple animation script—===
Whenever I take damage, I’m invincible for a second or two, thus preventing my player from accidentally touching the enemy twice within a second (Also giving the signature-in-all-games flashing).
===—I seriously have no clue how to replicate this—===
Because I want an action button, whenever my character comes in contact with a trigger for a sign (someone/something to talk to), I want my jump button to turn into the “Talk to someone” button (And then display some GUI…)
===—I can get this to run easily, but the problem is that if I just script it to run off of the jump button, my character will jump and talk at the same time… I also don’t know how to pull up GUI speech.
These are little ascetic things that make it look nice.
Whenever I die, unlike the Lerpz Tutorial, my character will play the “death” animation, allow my screen to do a “wipe”, while the screen is black, respawn me, and then show the screen again with a reverse wipe. (The wipe also applies for when I “Fall off”, but instead of dying, I just lose an HP. If I die when I fall off, the game would calculate that manually.)
—Also applying that my “recovery” items respawn themselves in the right spot if they were ordinarily pick-up-able—
I want my player to be able to change the settings in-game, that way I can play with a controller (Like hooking up my WiiMote and then playing that way for example X3),
—Do you even know how to use GUI?
Yes and no >.> Other than the Lerpz Tut, I have no idea how to implement such things as the options/settings menu, saving, loading, and other such stuff.
Any help is appreciated :3 Thanks and toodles continues working on other simple scripts
The OnControllerColliderHit function gets passed a ControllerColliderHit object which contains details of the collision. In particular, it contains the GameObject that was hit. You can call SendMessage on this GameObject to activate a damage/kill function. You can check if the enemy was underneath the player by subtracting the character’s position from the hit position (as reported by the ControllerColliderHit object). If the resulting vector has a negative Y component, it means the hit was basically below the character. If the character’s anchor point is at its feet then you just need to test for negativity:-
function OnControllerColliderHit(hit: ControllerColliderHit) {
var hitVec = hit.point - transform.position;
if (hitVec.y < 0) {
hit.gameObject.SendMessage("Kill");
} else {
// Player didn't jump on enemy.
}
}
You just need a boolean variable in the code to denote that the player is invincible. You can start a coroutine to handle the flashing and go back to normal mode after a couple of seconds:-
var invincible: Boolean;
function InvincibleMode(duration: float) {
invincible = true;
var startTime = Time.time;
while (Time.time - startTime < duration) {
renderer.enabled = false;
yield WaitForSeconds(0.1);
renderer.enabled = true;
yield WaitForSeconds(0.1);
}
}
You call the InvincibleMode function as the character takes damage:-
if (hit !invincible) {
// Apply damage here...
InvincibleMode();
}
You can use OnTriggerEnter/OnTriggerExit to tell when the character is in one of the talk zones (these functions get called on the character as well as the trigger object):-
function OnTriggerEnter(other: Collider) {
talkMode = true;
}
function OnTriggerExit(other: Collider) {
talkMode = false;
}
Then, when you test for the jump button, don’t jump if the talkMode flag is true.
Not sure quite which part of that you are having trouble with.
You can test for more than one control at once. For example, the Horizontal and Vertical axes for Input.GetAxis check the joystick, the arrow keys and WASD. See the input manager manual page for details.
Thanks for the help :3 That was all I was looking for, was help.
For #4, what happens is that I respawn right away; a while later after finding some more respawning things (because I’m having a problem with my respawn part of the third person status code, so I’m looking for that), I found that I can just send the “die” function in the third person status code to another function to play all of my death scripts such as wipes, GUI, and other such things.