Difference between revisions of "Talk:SetVelocity"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Jaime74
m
imported>Machina lucis
(3/64 = ScriptEffectElapsedSeconds?)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Velocity, Friction, and Gravity ==
Velocity has to be applied every frame in order to work. I ran into a few problems trying to move Idle NPCs. It seems impossible to overcome the initial friction but moving them few units higher above where they are standing before trying to apply velocity should do the trick:
Velocity has to be applied every frame in order to work. I ran into a few problems trying to move Idle NPCs. It seems impossible to overcome the initial friction but moving them few units higher above where they are standing before trying to apply velocity should do the trick:


Line 27: Line 29:
:[[User:DragoonWraith|<span style="font-family: Oblivion; size=2;">D</span>ragoon <span style="font-family: Oblivion; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion; size=2;">TALK</span>]] 19:02, 13 August 2011 (EDT)
:[[User:DragoonWraith|<span style="font-family: Oblivion; size=2;">D</span>ragoon <span style="font-family: Oblivion; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion; size=2;">TALK</span>]] 19:02, 13 August 2011 (EDT)


<hr>
:It appears to me that 64/3 is merely the average number of script effect updates per second. I use the following code snippet to send an actor skyrocketing at a given velocity (assuming the actor IsInAir already, for example, when it is jumping or falling); I'd appreciate it if someone else can try and see if it works for them too.
<pre>
set zeroVelocity to - (GetLocalGravity Z) * ScriptEffectElapsedSeconds
set velocity to velocity + zeroVelocity
SetVerticalVelocity velocity
</pre>
:If this is true, then Bethesda must be using the most simplified form of the Euler method (the kind I used in high school) for their physics...
:[[User:Machina lucis|machina lucis]] 10:27, 31 May 2012 (EDT)
 
=== Non-Z Gravity ===
 
You can set gravity in non-vertical directions by using [[SetLocalGravityVector]], in which case your code using SetVelocity would have to account for the non-Z components of gravity as well. Thus, I've reverted Mitchalek's edit: "each" was correct.<br/>
[[User:DragoonWraith|<span style="font-family: Oblivion; size=2;">D</span>ragoon <span style="font-family: Oblivion; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion; size=2;">TALK</span>]] 13:24, 6 September 2011 (EDT)
 
== Underwater? ==
 
Is it true that this function has no effect at all while an actor is swimming or under water? I've been trying around a lot, but once you're in water, any effect seems to be ignored. The same seems to apply for SetLocalGravity.
Is it true that this function has no effect at all while an actor is swimming or under water? I've been trying around a lot, but once you're in water, any effect seems to be ignored. The same seems to apply for SetLocalGravity.
Please check also my post about this in the tesnexus forums here: [http://www.thenexusforums.com/index.php?/topic/426711-obse-question-how-to-change-gravity-under-water/].
Please check also my post about this in the tesnexus forums here: [http://www.thenexusforums.com/index.php?/topic/426711-obse-question-how-to-change-gravity-under-water/].


[[User_talk:jaime74|jaime74 10:01, 27 August 2011 (EDT)]]
[[User_talk:jaime74|jaime74 10:01, 27 August 2011 (EDT)]]
:I suggest that you mention this in the [http://forums.bethsoft.com/index.php?/topic/1217754-relz-oblivion-script-extender-obse-0020-unofficial/ OBSE thread] on the official forums. To the best of my knowledge, it is the only place that anyone from the OBSE team checks regularly. That includes the Wish List.
:Also, you can use <tt><nowiki>~~~~</nowiki></tt> to sign comments easily, rather than typing out your signature each time, which it appears you've maybe done?
:[[User:DragoonWraith|<span style="font-family: Oblivion; size=2;">D</span>ragoon <span style="font-family: Oblivion; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion; size=2;">TALK</span>]] 16:00, 27 August 2011 (EDT)

Latest revision as of 09:27, 31 May 2012

Velocity, Friction, and Gravity[edit source]

Velocity has to be applied every frame in order to work. I ran into a few problems trying to move Idle NPCs. It seems impossible to overcome the initial friction but moving them few units higher above where they are standing before trying to apply velocity should do the trick:

target.MoveTo target 0 0 5


Trigonometry is a must and calculating movement vectors with sin and cos:

Set cos to (source.GetPos x - target.GetPos x) / source.GetDistance target

Set sin to (source.GetPos y - target.GetPos y) / source.GetDistance target


Then multiply desired velocity on X with cos and Y with sin values to get target move from/to the source.

Another problem I ran into was that game seems to apply gravity before velocity so I had to find a constant value that I would apply to Z axis in order to negate initial gravity or target would fall to the ground and cease to move because of the friction. I did some testing there using GetLocalGravity and value was something like -515. I tried experimenting with different Z velocities values until I reach antiG state and I found a sweet spot around 24 and I came to a conclusion that its actually gravity which is expressed in game units converted to feet by multiplying with (21+1/3). So in order to get that antiG constant use:

Set antiG to (GetLocalGravity Z) / (21+1/3) * -1


I hope it helps. ;) Mitchalek 04:57, 17 August 2011 (EDT)

Useful stuff; the game can be really inconsistent about its conversion from feet to units and back (sometimes it seems to use just 21, other times 21.3333 with some arbitrary number of threes that seems to vary from place to place). Glad that you've fiddled with this; I'm going to mention the gravity thing on the page.
You are, by the way, welcome to update the page itself with these kinds of findings. I do recommend taking a look at Help:Editing for some pointers, though; italics aren't the best choice for code.
Also, please sign your comments in Discussion pages by ending with ~~~~; that will insert your username and a timestamp. Thanks!
Dragoon Wraith TALK 19:02, 13 August 2011 (EDT)
It appears to me that 64/3 is merely the average number of script effect updates per second. I use the following code snippet to send an actor skyrocketing at a given velocity (assuming the actor IsInAir already, for example, when it is jumping or falling); I'd appreciate it if someone else can try and see if it works for them too.
set zeroVelocity to - (GetLocalGravity Z) * ScriptEffectElapsedSeconds
set velocity to velocity + zeroVelocity
SetVerticalVelocity velocity
If this is true, then Bethesda must be using the most simplified form of the Euler method (the kind I used in high school) for their physics...
machina lucis 10:27, 31 May 2012 (EDT)

Non-Z Gravity[edit source]

You can set gravity in non-vertical directions by using SetLocalGravityVector, in which case your code using SetVelocity would have to account for the non-Z components of gravity as well. Thus, I've reverted Mitchalek's edit: "each" was correct.
Dragoon Wraith TALK 13:24, 6 September 2011 (EDT)

Underwater?[edit source]

Is it true that this function has no effect at all while an actor is swimming or under water? I've been trying around a lot, but once you're in water, any effect seems to be ignored. The same seems to apply for SetLocalGravity. Please check also my post about this in the tesnexus forums here: [1].

jaime74 10:01, 27 August 2011 (EDT)

I suggest that you mention this in the OBSE thread on the official forums. To the best of my knowledge, it is the only place that anyone from the OBSE team checks regularly. That includes the Wish List.
Also, you can use ~~~~ to sign comments easily, rather than typing out your signature each time, which it appears you've maybe done?
Dragoon Wraith TALK 16:00, 27 August 2011 (EDT)