Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Get entity velocity?
Patacorow Offline
Member

Posts: 135
Threads: 11
Joined: Jul 2011
Reputation: 3
#1
Smile  Get entity velocity?

Hey, is there a way to check for a current entity's move speed?

like

If(VariableEntityMoveSpeed > 4)
{


}


Thanks! :>
(This post was last modified: 10-25-2011, 08:35 PM by Patacorow.)
10-25-2011, 08:34 PM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#2
RE: Get entity velocity?

Nope, sadly not. It isn't trivial to check for positions and use the change in position to get velocity either. You will probably have to consider your problem in a different way and take a new approach. What effect are you trying to achieve here?
(This post was last modified: 10-25-2011, 10:29 PM by Apjjm.)
10-25-2011, 10:28 PM
Find
Patacorow Offline
Member

Posts: 135
Threads: 11
Joined: Jul 2011
Reputation: 3
#3
RE: Get entity velocity?

I'm trying to make a puzzle where the player has to charge/throw something at a door to unlock it.

I need this to make this realistic, since making a simple collide callback will look ugly and lazy.
10-26-2011, 05:47 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#4
RE: Get entity velocity?

If you mean an effect like the rubble wall or glass in the study, that is done by "breaking" an object. This is in essence a collision callback, except it also takes prop damage into account. You could combine a collision callback and a change in prop health to determine whether or not to open the door.
(This post was last modified: 10-26-2011, 11:41 AM by Apjjm.)
10-26-2011, 11:41 AM
Find
Patacorow Offline
Member

Posts: 135
Threads: 11
Joined: Jul 2011
Reputation: 3
#5
RE: Get entity velocity?

nah I'm just trying to check if the prop is moving fast enough to activate a certain callback. thanks anyway I'll try to find a workaround. :p
10-26-2011, 01:54 PM
Find
Patacorow Offline
Member

Posts: 135
Threads: 11
Joined: Jul 2011
Reputation: 3
#6
RE: Get entity velocity?

(10-26-2011, 01:54 PM)Patacorow Wrote: nah I'm just trying to check if the prop is moving fast enough to activate a certain callback. thanks anyway I'll try to find a workaround. :p
ok that didn't work very well since I'm not too bright :S

can anyone from FG take a look at this?
10-26-2011, 03:56 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#7
RE: Get entity velocity?

All entities can be made to receive damage when an object is tossed at it. Upon losing all health the object can be replaced with a broken form of itself (or any other entity). You're going to have to edit the original entity and change its type to a type that can receive damage (e.g. Object). Then adjust the settings so that minimal damage can break the entity and once broken gets replaced with the broken form of the entity.

The only thing you may notice using this method is that swinging objects on the entity won't necessarily break it, and may require the player to toss an object at it.

Tutorials: From Noob to Pro
(This post was last modified: 10-26-2011, 08:29 PM by Your Computer.)
10-26-2011, 08:28 PM
Website Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#8
RE: Get entity velocity?

There's a little trick you could try, but it requires debugging and testing work on your end. What we're going to do is create a "dummy" entity to place over or in front of the real entity and the player will actually break the dummy. Open the model editor and import the mesh under static_objects > castlebase > floor > "deafault.dae" (yes that's how it's spelled in my Amnesia for some reason. The reason I'm choosing this mesh is that it's thin and is one-sided, so you can flip it over or any way you like to make it harder for the player to spot.

Select the mesh. Make its size 0.01 for X, Y and Z. Create a shape that matches the kind of object you want to actually break in-game. (e.g. If it is a door, make the body shaped like a door. This is what I mean by debugging and testing. You'll need to turn on Physics Debug in-game and make sure the body size of this custom entity we're making matches the object you want to break. Create a body from that shape and assign it a material type. Go to User-Defined Variables (under the Settings drop-down menu). Change the object type to Object > Static. Scroll down and check the BreakActive box.

Now place this object into the level. If you have trouble clicking on it (because the actual mesh is so small) press ctrl + F and search for the name of the entity then click on it.

Orient it, etc etc. In your script file you can then script this:

PHP Code: (Select All)
void OnStart()
{
    
SetEntityCallbackFunc("dummy_ent""BREAKFUNC");
}
void BREAKFUNC(string &in entitystring &in type)
{
    if(
type == "Break") { /*break the real entity here!!!*/ }


When the dummy entity is broken, you can run whatever scripts you want, even if it doesn't involve breaking something. This is just a clever way of "testing" the speed of an object when it hits another by whether or not the latter breaks. This requires a bit of testing some time commitment, especially seeing as I've never tried this, but this is just a solution that came to mind to your problem. And that's the price we have to pay as developers if we want to bring fresh and fun content to players Tongue

(This post was last modified: 10-27-2011, 10:00 PM by palistov.)
10-27-2011, 09:56 PM
Find
Patacorow Offline
Member

Posts: 135
Threads: 11
Joined: Jul 2011
Reputation: 3
#9
RE: Get entity velocity?

Brilliant idea, though wouldn't the player be able to accidentally break the dummy entity before colliding with the door?
10-31-2011, 08:58 PM
Find




Users browsing this thread: 1 Guest(s)