addObject() 'time' parameter inconsistent #40402

Closed
opened 2014-05-28 07:01:19 +02:00 by Raf Colson · 18 comments

System Information
Windows 7 64 bit, Nvidia GeForce GT540M Cuda

Blender Version
Never worked. (tested with 2.63 up to current Hash 7fb33e5)

Short description of error
The 'time' parameter of addObject() gives inconsistent results. Generally the added object lives longer as it should. With 'time' set to 1, the object lives 2 logic tics. With 'time' set to 10, for example, the object lives 13 logic tics.

Exact steps for others to reproduce the error
Play the game. Check the messages in the System Console.

AddObject_life_bug.blend

**System Information** Windows 7 64 bit, Nvidia GeForce GT540M Cuda **Blender Version** Never worked. (tested with 2.63 up to current Hash 7fb33e5) **Short description of error** The 'time' parameter of addObject() gives inconsistent results. Generally the added object lives longer as it should. With 'time' set to 1, the object lives 2 logic tics. With 'time' set to 10, for example, the object lives 13 logic tics. **Exact steps for others to reproduce the error** Play the game. Check the messages in the System Console. [AddObject_life_bug.blend](https://archive.blender.org/developer/F91678/AddObject_life_bug.blend)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @raco

Added subscriber: @raco
Author

It probably has something to do with the built-in standard of 50fps for the Add Object Actuator. Notice in the example blend file that on the 6th tic, life shows 5.

It probably has something to do with the built-in standard of 50fps for the Add Object Actuator. Notice in the example blend file that on the 6th tic, life shows 5.

Added subscriber: @Moguri

Added subscriber: @Moguri

Yeah, the life/time parameter is a pseudo-second of sorts. It looks like it assumes 50fps, which is not very accurate:

	if (lifespan > 0)
	{
	*add a timebomb to this object* for now, convert between so called frames and realtime
		m_tempObjectList->Add(replica->AddRef());
	*this convert the life from frames to sort-of seconds, hard coded 0.02 that assumes we have 50 frames per second* if you change this value, make sure you change it in KX_GameObject::pyattr_get_life property too
		CValue *fval = new CFloatValue(lifespan*0.02);
		replica->SetProperty("::timebomb",fval);
		fval->Release();
	}
Yeah, the life/time parameter is a pseudo-second of sorts. It looks like it assumes 50fps, which is not very accurate: ``` if (lifespan > 0) { ``` *add a timebomb to this object* for now, convert between so called frames and realtime ``` m_tempObjectList->Add(replica->AddRef()); ``` *this convert the life from frames to sort-of seconds, hard coded 0.02 that assumes we have 50 frames per second* if you change this value, make sure you change it in KX_GameObject::pyattr_get_life property too ``` CValue *fval = new CFloatValue(lifespan*0.02); replica->SetProperty("::timebomb",fval); fval->Release(); } ```

If this is fixed to be actual seconds, it could break existing games. So, this probably isn't worth fixing. On the other hand, it is hard to be precise with the time parameter since it is based on framerate. If precision is an issue, you can always use the Python time module and KX_GameObject.endObject() to handle this yourself.

If this is fixed to be actual seconds, it could break existing games. So, this probably isn't worth fixing. On the other hand, it is hard to be precise with the time parameter since it is based on framerate. If precision is an issue, you can always use the Python time module and KX_GameObject.endObject() to handle this yourself.
Author

I don't really see how it would break existing games if the value would be determined by the logic tic rate.

CValue *fval = new CFloatValue(lifespan/getLogicTicRate())
I don't really see how it would break existing games if the value would be determined by the logic tic rate. ``` CValue *fval = new CFloatValue(lifespan/getLogicTicRate())

It would alter the timing, which could throw off existing games.

It would alter the timing, which could throw off existing games.
Author

Hi moguri,

Thanks for answering.

I think you're talking about the case where game developers purposely used other values to work around this limitation. For example, setting time to 50 so the object is removed after one second, even when the logic tic rate is 60.

If such a developer would like to run/export his (old) game with a Blender version without this limitation, indeed he would be forced to change time to 60. But if you ask me, I think he would gladly do so, because he'll never have to deal with this limitation ever again, when working on future projects.

I will ask people for their opinion on the Blender Artists Forum and keep you posted.

Thanks

Hi moguri, Thanks for answering. I think you're talking about the case where game developers purposely used other values to work around this limitation. For example, setting time to 50 so the object is removed after one second, even when the logic tic rate is 60. If such a developer would like to run/export his (old) game with a Blender version without this limitation, indeed he would be forced to change time to 60. But if you ask me, I think he would gladly do so, because he'll never have to deal with this limitation ever again, when working on future projects. I will ask people for their opinion on the Blender Artists Forum and keep you posted. Thanks

I was thinking more off people you just played with the number until it "felt right." These people will have their games subtly changed. This may be a problem or it may not. Regardless, this won't be fixed for 2.71, since I don't want to introduce any potentially game breaking changes at this stage.

Also, if this is going to be changed, it will be changed to just use seconds, and not be framerate dependent.

I was thinking more off people you just played with the number until it "felt right." These people will have their games subtly changed. This may be a problem or it may not. Regardless, this won't be fixed for 2.71, since I don't want to introduce any potentially game breaking changes at this stage. Also, if this is going to be changed, it will be changed to just use seconds, and not be framerate dependent.

Added subscriber: @AngusHollands-4

Added subscriber: @AngusHollands-4

I feel that whilst this is a valid argument, there are already enough inconsistencies in the engine timing design as it is, and we should address them asap.

If it breaks existing games, it won't be difficult to alert users of the change. New users should find it simpler to use with seconds. I don't believe we should encourage "compatibility" with such bugs, especially when they aren't mainstream features (the life attribute of an object is rarely used by most blend files I've investigated).

I feel that whilst this is a valid argument, there are already enough inconsistencies in the engine timing design as it is, and we should address them asap. If it breaks existing games, it won't be difficult to alert users of the change. New users should find it simpler to use with seconds. I don't believe we should encourage "compatibility" with such bugs, especially when they aren't mainstream features (the life attribute of an object is rarely used by most blend files I've investigated).
Member

Added subscriber: @brita

Added subscriber: @brita

If we change over to seconds for this, some other (potentially breaking) changes would happen as a result:

  • The lifetime would no longer be framerate dependent (this could alter timing, but would overall be a good change)
  • KX_GameObject.life would return values in seconds instead of frames (the docs say seconds, but currently the number of frames/tics remaining is actually being returned)
If we change over to seconds for this, some other (potentially breaking) changes would happen as a result: * The lifetime would no longer be framerate dependent (this could alter timing, but would overall be a good change) * KX_GameObject.life would return values in seconds instead of frames (the docs say seconds, but currently the number of frames/tics remaining is actually being returned)
Author

I'm all for changing to seconds. You can read about opinions on BA: Your opinion about fixing the addObject 'time' parameter?

I'm all for changing to seconds. You can read about opinions on BA: [Your opinion about fixing the addObject 'time' parameter? ](http://blenderartists.org/forum/showthread.php?338508-Your-opinion-about-fixing-the-addObject-time-parameter)
Author

Maybe this could be changed from type 'Bug' to 'To do' or 'Design'. I think we all agree that changing to seconds is the best solution.

Maybe this could be changed from type 'Bug' to 'To do' or 'Design'. I think we all agree that changing to seconds is the best solution.

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Dalai Felinto self-assigned this 2014-08-27 12:39:46 +02:00

Agree on changing to seconds when we feel like breaking compatibility again (3.x?). Moved to the TODO . Thanks for the report.

Agree on changing to seconds when we feel like breaking compatibility again (3.x?). Moved to the [TODO ](http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/GameEngine#Python_API). Thanks for the report.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#40402
No description provided.