Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / My solution for the play object command not working

Author
Message
Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 23rd Feb 2012 06:08 Edited at: 23rd Feb 2012 14:32
I recently had a problem with the play object command not working or freezing on a single frame so I turned to the forum to find a solution but found others with the same problem and other work arounds did not suit my needs, so I came up with this function to solve my problem.
Now I'm sure someone has done this but did not share with the community, and to them I say shame on you!




add this function to your loop and then just use the command "playobject(object number, start frame, end frame)"
in your do "do" section
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 23rd Feb 2012 07:21
I'm afraid we can't just copy/paste the code and use it. It will require adapting as not all of us have a variable called 'death' or want object '3' to play but nevertheless, it's good to see you contributing to the community .

Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 23rd Feb 2012 14:34
OOPS! your right Hodgey, thanks.

Re edited first post
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Feb 2012 14:44
I find it easier to just control my object frames manually, lets me set the speed, interpolation, animation transitions etc etc. Don't use or mimic Play Object, it limits you and limits how smooth your animations can look. For example, I often set the interpolation high then sharply reduce it when changing the animation, say from standing still to running.

For example, similar to your function, but no need for looping animations, just setting the frame...





One benefit of this is that you can reverse animations really easily, just use a negative value in the speed parameter, and have it limit the frame for the start and end. Also, if you pause the game, you just don't call the object update functions, so they won't keep looping even when the game is paused, or while your doing 2D stuff for instance.

Health, Ammo, and bacon and eggs!
Millenium7
21
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 23rd Feb 2012 16:26
Quote: "I find it easier to just control my object frames manually"


be careful with this. I havn't tested it myself but came across a thread discussing it. Apparently DBPro actually loops through all animation frames when setting it manually. So if you set the frame to 120, it does not instantly jump to 120. It goes frame 1,2,3,4....119,120 in the background until it finds the right one. Something to do with how the .x format works?

The result is this is noticeably slower than simply calling the loop/play object commands. And it gets progressively worse as the frame number goes up
SoftMotion3D
AGK Developer
20
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 23rd Feb 2012 18:21 Edited at: 23rd Feb 2012 18:22
play object command??? it works fine... whats the problem with it??

edit: animation freezing..... humm... what application are you using that develops a .x or 3ds that freezes? As even my own application works fine and have never had such problems...

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Feb 2012 22:14 Edited at: 23rd Feb 2012 22:17
Here's how I've been doing it with all of my projects:



Call InitAnimation() before your main loop and put ControlAnimation() in your main loop.

I should probably add this to my library of functions for you guys.

[EDIT] Just noticed that there are some functions in the code specifically for my project. You'll have to comment them out for this to work.

TheComet

Section 812
18
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 23rd Feb 2012 23:27
Now this is what I would have like to have found in the first place.
I only found 3 posts that pertained to my exact problem when I went to search for the solution, so I knew that not everyone had the problem.
I only wanted the play object command for my purpose, didn't need to interpolate or change speed but these things will be handy for a future project.

why do I only want that? Its G14 classified, and you don't have clearance. LOL

@ SMD_3D Interactive :I cant explain how or why I had this problem as I had done the play object command in a separate application with no other code to see If I had some conflicting code but I still ended up with the same result. mabe I have a damaged or incomplete library in my DBPro or something.

all that aside, I've not had to post in this section before and I want to Thank you all for your comments and methods and not spilling gasoline on me while I smoke.

humor = 0
do
if humor<0
dontlaugh=1
endif
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 27th Feb 2012 03:27 Edited at: 27th Feb 2012 03:37
Your object is probably not looping at End# try changing it to catch values above End# also.



Loop Object command (and play object) can advance the literal frame past the final frame specified if the second last frame is close but not quite at the end.


Also what Van B wrote is important:

Quote: "I find it easier to just control my object frames manually..."


In addition to the reason he gave, if you sync more that one camera, like when using advanced shaders, animations will update/advance when ever a camera is synced. This is a problem when you need to sync several times for each time the screen is updated/synced. It can cause rapid and irregular animation speeds unless you manually control object animations.


Quote: "Millenium7 Said:
be careful with this. I havn't tested it myself but came across a thread discussing it. Apparently DBPro actually loops through all animation frames when setting it manually. So if you set the frame to 120, it does not instantly jump to 120. It goes frame 1,2,3,4....119,120 in the background until it finds the right one. Something to do with how the .x format works?"


Never seen this happen with the "Set Object Frame" command. Could this be a very old and fixed bug?

Login to post a reply

Server time is: 2026-07-09 23:12:39
Your offset time is: 2026-07-09 23:12:39