Jump to content

need some papyrus help, getposition and applyhavokimpuse


Recommended Posts

import debug
import game
import utility
float transX 
float transY 
float transZ 

objectReference property myTarget auto
Actor Property PlayerRef Auto

EVENT OnLoad()

	registerForSingleUpdate(1)
	myTarget = getplayer()
	
EndEvent

EVENT onUpdate()

	if getDistance(myTarget) >= 2048
		if getParentCell() == myTarget.getParentCell()
			moveto(mytarget,0,0,130)

		elseif getParentCell() != myTarget.getParentCell()
			moveto(mytarget,0,0,130)
                endif

	else

	   jumpAt(myTarget)

	endif

			
	registerForSingleUpdate(Utility.randomFloat(1.5,3.0))
	
endEVENT

function JumpAt(objectReference target)

	if getDistance(target) > 64 && getDistance(target) < 2048

		transX = (target.getPositionX()) - (getPositionX())
		transY = (target.getPositionY()) - (getPositionY())
		transZ = (target.getPositionZ()) - (getPositionZ() + 256)
		
		float impulseStrength = (getDistance(target)/16)
		if impulseStrength > 100										; clamp value to avoid silly numbers
			impulseStrength = 99
		endif
		applyHavokImpulse(0,0,64,8)

		;tee it up, then hit towards target
		wait(0.4)
		applyHavokImpulse(transX, transY, transZ, impulseStrength)

	
	elseif getDistance (target) <= 64
		applyhavokImpulse(0,0,64,8)		; little happy jumps when near the target

	endif
	
endFunction

ive attached this script to a misc object. if i spawn it in it works as expected. it follows you around and in and out of interiors. hops in place if its near the player.

but if i pick it up and drop it from my inventory, they start flying all over the place. never stopping

 

its also like a virus, if i pick one up and drop it from my inventory, the ones i spawn in fly all over as well.

 

im not certain whats causing this at all.

 

Link to comment
Share on other sites

When you spawn it in place, the object is at rest and your script is able to manipulate the object.

When you drop it from inventory, the object literally drops to the ground and the mesh's havok settings take affect. If those are not correct, the item can bounce around like crazy. Add in your script trying to manipulate it and the object will probably never settle down in order to be properly manipulated.

 

I recommend that you find a similar weighted object in the base game and adjust your mesh's havok settings to fall in line. How exactly to do that? Don't ask me. I just know that that is the most likely cause.

Link to comment
Share on other sites

When you spawn it in place, the object is at rest and your script is able to manipulate the object.

When you drop it from inventory, the object literally drops to the ground and the mesh's havok settings take affect. If those are not correct, the item can bounce around like crazy. Add in your script trying to manipulate it and the object will probably never settle down in order to be properly manipulated.

 

I recommend that you find a similar weighted object in the base game and adjust your mesh's havok settings to fall in line. How exactly to do that? Don't ask me. I just know that that is the most likely cause.

 

Looks like maybe ill just have to have to destroy the object when its picked up and give the crafting materials back, or just make it a spell like an atronach.

 

Thank you for the reply!

Link to comment
Share on other sites

You could allow the player to assign a representation item to a favorite slot and "use" it from there (or apply a hotkey using SKSE). When used, spawn an instance of the real item a short distance from the player. It would be the same idea as a spell but using a "non magical" approach.

Link to comment
Share on other sites

Play around with BSX values in the nif. Use a value other objects (without that issue) use if you happen to be aware of any examples. Otherwise there is also SetMotionType() you can play with. 4 is commonly used for keyframe, and theres another called dynamic. Check out the objectreference script to see what you can choose

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...