Event Triggering Problem

Game Editor comments and discussion.

Event Triggering Problem

Postby Turon » Fri Jul 12, 2013 6:29 pm

The Player has an up event which must only be trigger onces a user variable is triggered when the
Player collides with a certain actor, I use the 'if' statement. if the variable is not triggered now why is
It that the up even will proceed anyway before it is allowed to?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Event Triggering Problem

Postby Grynde » Sat Jul 13, 2013 4:57 am

If you post the problem code, someone on here is bound to figure it out.

You may try to make the variable true only when a)collision occurs and b) key is pressed
i.e. (within the collision of your trigger actor)
Code: Select all
char*key=GetKeyState();
if(key[KEY_UP]==1)
{
//variable goes here
}


This way the variable should function as intended only after Up is pressed and only while collision occurs. Which I'm guessing is what you are asking.
Playing a game is the voluntary attempt to overcome unnecessary obstacles.
-Bernard Suits
User avatar
Grynde
 
Posts: 21
Joined: Fri Apr 26, 2013 12:41 pm
Location: Virginia
Score: 1 Give a positive score

Re: Event Triggering Problem

Postby Turon » Sat Jul 13, 2013 8:30 am

The brown object is the trigger actor. and I put your code in it and
The up event still works when I press up the event that is to be triggered is this
Code: Select all
if(crawlup=1)
yvelocity = yvelocity - 1;
This code is only supposed to work while the player is colliding with the brown object.
the player is supposed to crawl up the brown object as the player can't jump very high.
Attachments
Demonstration of the Physics.png
The red line shows how the player is supposed to walk no jumping inolved the player sticks to the brown object
The Orange line shows how high the player can jump
Last edited by Turon on Sun Jul 14, 2013 11:54 am, edited 2 times in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Event Triggering Problem

Postby skydereign » Sat Jul 13, 2013 9:43 am

You need to have two equal signs in your if statement. Because you only have one, it sets crawlup equal to 1.
Code: Select all
if(crawlup==1)
{
    yvelocity = yvelocity - 1;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Event Triggering Problem

Postby Turon » Sat Jul 13, 2013 10:30 am

I tell you Its collision event and It will proceed even if if there is no collision why?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Event Triggering Problem

Postby Grynde » Sat Jul 13, 2013 2:49 pm

If you copy Sky's code, you should get the desired results.

In your original code, you were also missing your brackets {}which would also explain why yvelocity was increasing outside of the collision.

Hope that helps.
Playing a game is the voluntary attempt to overcome unnecessary obstacles.
-Bernard Suits
User avatar
Grynde
 
Posts: 21
Joined: Fri Apr 26, 2013 12:41 pm
Location: Virginia
Score: 1 Give a positive score

Re: Event Triggering Problem

Postby Turon » Sat Jul 13, 2013 3:15 pm

Thanks Skyderein and Grynde it prevented the player from flying before colliding. :D
But how do you stop the player from flying after the player no longer touches that brown object (that I incorecty discribed as white)?. :wink:
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Event Triggering Problem

Postby Grynde » Sat Jul 13, 2013 3:28 pm

Glad it worked. :D

Use a collision finish with your collide object
Code: Select all
crawlup=0;
Playing a game is the voluntary attempt to overcome unnecessary obstacles.
-Bernard Suits
User avatar
Grynde
 
Posts: 21
Joined: Fri Apr 26, 2013 12:41 pm
Location: Virginia
Score: 1 Give a positive score

Re: Event Triggering Problem

Postby Turon » Sun Jul 14, 2013 10:25 am

Thanks...Hmm
I made a change animation even to go with it that the code now looks like this
Code: Select all
if(crawlup==1)
{
    yvelocity = yvelocity - 1;
}

ChangeAnimation("Event Actor", "Player Right Flip", NO_CHANGE);

if(FlipPlayer==1)
{
    ChangeAnimation("Event Actor", "Player Right Double Flipwalk", NO_CHANGE);
}


I would like the Player to always change to an alternate animation while colliding on the right side of the brown object.

The FlipPlayer user variable is trigger in a collision event felt by the brown object from the left side of the Player and uses the this code.

Code: Select all
char*key=GetKeyState();
if(key[KEY_UP]==1)
{
FlipPlayer==1;
}

now for some reason it still does not do what I like it to do
hope the image will help.
Attachments
Demonstration of the Physics 2.png
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Event Triggering Problem

Postby AliceXIII » Mon Jul 15, 2013 3:03 am

The FlipPlayer user variable is trigger in a collision event felt by the brown object from the left side of the Player and uses the this code


Your FlipPlayer variable is used only in a collision with the left side of the brown object?

If so you need to make a collision event for the right side of the object as well calling a collision event on the left side will only return true if there is a collision on the left side, If you don't make a collision event for the right side then you can't collide with the right side.
"Taking a breath of fresh air."
User avatar
AliceXIII
 
Posts: 325
Joined: Fri Sep 17, 2010 2:36 am
Location: victoria, texas
Score: 37 Give a positive score

Re: Event Triggering Problem

Postby Turon » Mon Jul 15, 2013 8:53 pm

To be Honest I figured out the last part by just by fiddling around with things I have learn from past experience,, Thanks for the Hint AliceXIII.
I have realize the most important thing wen working in Programing is to look at every detail, if the game does not do what you want you may still have :D
nearly the right code!
The way you organize the codes can effect the way it works.
The Number of = signs and + sign and number all effect stuff, and by alternating these factors I figured it out!

Collision Right side of Player(BrownObject)
Code: Select all
char*key=GetKeyState();
if(key[KEY_UP]==1)
{
FlipPlayer=1;
}
if(FlipPlayerR=1)
FlipPlayer=0;

Collision Left side of Player(BrownObject)
Code: Select all
char*key=GetKeyState();
if(key[KEY_UP]==1)
{
FlipPlayerR=1;
}
if(FlipPlayer=1)
FlipPlayerR=0;


And this is the Up Event of the Player
Code: Select all
if(crawlup==1)
{
    yvelocity = yvelocity - 1;
}
if(FlipPlayerR==1)
{
    ChangeAnimation("Event Actor", "Player Right Flipwalk", NO_CHANGE);
}
if(FlipPlayer==1)
{
    ChangeAnimation("Event Actor", "Player Right Double Flipwalk", NO_CHANGE);
}


THIS WORKS! And Thanks for The help I have finally got a Better grip on Programing!
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest