How can i damage my FirstPersonCharacter's health constantly while it's in the trigger zone? It loses its damage only when it enters onBeginOverlap on the trigger zone.
Here is my blueprint:
Create Timer with your DamageOverTime function and call him every X sec, until onEndOverlap occur.
simple example:
Here you can find much more about timers in BP
In c++ I would connect it either to the time handle or Tick event which is using delta seconds, but I'm not into blueprints yet so I can give you a small advice to start off with.
You need a loop and check if the character is in the zone or not. The easiest way is to set a bool variable, set it to true when it enters, and keep damaging while the variable is true and stop it when it's set back to false (when he leaves the zone).
Hope it helps a bit.
Related
so my model works fine, but since I introduced conditional events (= an event that triggers once a specified condition is met), I find that the computational performance is decreased.
This is especially annoying when I run experiments with many iterations...
Is there an alternative way to trigger an event at a specified condition?
Thank you :)
The answer to this will be triggering events directly by the mechanism that are influencing the conditions you are monitoring. So instead of having the "permanent" condition check, make sure that each time the condition changes you are triggering a check. If that is not possible, because there are too many influencing factors, or it is continuosly changing, consider a cyclic check in discrete timesteps at an interval that suits you. Even this will be much more performant (depending on your choosen time check interval) then the current continous monitoring.
Example on how to do an event trigger monitoring instead of continous monitoring:
In your main, add global counter variable of type int (here: nrAgentsState1) and create a function to update that variable (here: updateStateCounter). Also in the function: a check that triggers a function whenever your threeshold is reached.
In your transition leading into the state you want to monitor (here: state1), call the function in main that updates the global counter. For the transition leading out of the monitored state, add the same action, but with a -1 as parameter.
What would be the best way to incorporate changing tide times into an AnyLogic model? I would like to use the times to effectively block and unblock a port. I have looked at the schedule option and the format (Start: Day1, Time) doesn't seem the best way to do it.
You can model the tide by a reoccuring timed trigger.
AnyLogic offers the Dynamic Event for this, an event that can reschedule itself.
Depending on how you have the time data for the tides (list of DateTimes, fixed periods, database), you can retrieve that value for each new rescheduling of the dynamic event.
I attached a screenshot of a simple sample model. Here I assume you have got a list with the interval in minutes between each port-affecting tide moment (Low Tide/Port Blocked - High Tide/Port Open - Low Tide/Port Blocked - and so on....) . The dynamic event then sets a boolean variable portBlocked, but depending on your needs you could also trigger a Statechart Transition, block flowchart modules, or trigger a function.
The Action code of the Dynamic Event:
portBlocked=!portBlocked;
create_MyDynamicEvent(tideIntervalsInMinutes.get(tideCounter),MINUTE);
tideCounter++;
Explanation of the code:
Trigger your needed actions (here simple boolean variable)
Reschedule the event for the next tide change
Update the tide counter (used to retrieve the corresponding tide interval time from the list)
In the startup code of the model you will have to trigger the Dynamic Event once initially, for this just use the same code as point 2 above.
I am interested in capturing the time a particular material handler(AGV in my case) spends at a particular node before it is released. Is there a way to do so?
This works in general, since I don't know anything about your model (there are many other ways depending on what you are doing):
Create a variable and make it equal to time when your AGV arrives to the node:
timeWhenArrivesToNode=time();
Create another variable and make it equal to the amount of time it spent in that node... This code should be executed at the moment when the AGV leaves the node:
timesWhenItIsReleased=time()-timeWhenArrivesToNode;
Of course the answer will have the time units of your model.
GameKit allow us to end a turn with a timeout for the next participant in the match. However, I couldn't find a way to set a timeout for the first participant for its first move. Is there anyway to do that?
EDIT
It started to make sense to me why Apple would leave this out from GameKit. When you just join a GKTurnBasedMatch you will always be in turn so there's no need for a timeout considering that it was added to avoid frustration on players while waiting too long for their turn. The thing is that my use case for a timeout is different. I'm designing a tournament and a timeout means that you lost the match, no matter it's the first turn or not. So I always need to have the ability to timeout the current turn. I'm afraid I'll need to implement this on the server which just sucks.
Might be a little late on this one, but Game Center TBM timeouts don't work like that.
When you call endTurnWithNextParticipants you must provide a list of players that will receive the turn if the previous one times out. If you want a player to lose the game when he/she times out, you must implement this e.g. on the client of the next player that receives the turn, Apple serves won't do this for you.
Based on what you're aiming for, I think the best implementation would be to check for the time the latest turn was played, or the match creation time in case it's the first turn, compare it to the current system date and time and programmatically end the match if time is over.
Like you point out, as player1 on turn1, there aren't any other players yet, so I suspect that's why GC doesn't give us an interface to set the timeout for player1.
How about setting an NSTimer to the desired timeout, and then ending the turn when it fires?
If you're looking at a long timeout, say a few days, where the user might leave and then rejoin after the timeout, you could calculate the desired deadline by adding the timeout interval to the match start time, and store that in NSUserDefaults. On each game startup, check if the deadline has passed, and end the turn when appropriate.
I'm starting to work on an app similar to tamagotchi (virtual pet kind of stuff) in the Corona SDK. I got absolutely stuck and am out of ideas on how to get one part.
How can the game character, lets say "pet" change its status, e.g. become hungry or die while the game is inactive? Or maybe its possible to make the changes as the player enters the game the next time, maybe to bind it to the global time (still no idea of how to do it)?
I would appreciate any help.
The simplest I can think is to keep all relevant data in a file. The first datum would be a time stamp of the last time the game was turned inactive.
Every time the game is first activated it reads the file along with the time stamp. After a specific time length has passed the pet becomes hungry, tired, etc. If an extraordinary long time has passed the pet dies.
You can go further by putting a time stamp next to each datum like "last fed", "last watered", etc. and then you can make individual attributes expire at different times, including death by boredom by keeping the global "last active" time and if a long time has passed without running the game the pet dies.
I actually created an application like this. I created a number of states in a enum and then in a checkMoodState method I hardcoded the values that decided the state of the mood.
e.g.
timeSinceLastPlay
timeSinceLastFeed
or whatever.
Either write the dates to a plist for each variable you want to track and on each check or store them in NSUserDefaults(one function to write them all, one to load them all), subtract the current time from it. You will be left with a negative number, and you can just get its absolute value.
You decide whenever you want to check the last time since whatever it is you are checking, e.g. feeding. Create an NSTimer with the duration of the time between checks and in the method called by the timer, you do you checks and update the mood as you need.