Jump to content

door


PcWizKid
 Share

Recommended Posts

i have made a door model in blender and textured it and everything but now this is what i need: You walk up to the door and it displays a message on the screen "Press E to use" then when you press E the door opens. how might I do this? :)

 

 

thanks,

Garrett

Link to comment
Share on other sites

You can do this with a raytrace. I've tried to do this before by showing a hand icon on special objects, but I never got it working on purely the models I wanted it 2. place this in the main loop, before FW:Update.

pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,2.0),0,0)
	if pick~=nil then
		repeat
			if pick.entity:GetClass()==ENTITY_MODEL then
				break
			end
			pick.entity=pick.entity.parent
		until pick.entity==nil
		if pick.entity~=nil then
			showText =1
		end
	end

and then before the flipp command

SetBlend(1)

       if showText == 1 then
      DrawText("Press E to open door"GraphicsWidth()/2,GraphicsHeight()/2) 
       end

       SetBlend(0) 

 

or instead of a raytrace you can use EntityDistance:

if EntityDistance(fw.main.camera,door) <2 then
--showText=1
end

 

You can then either have code to rotate the door on it's Y axis or you play an animation.

Link to comment
Share on other sites

ok i did everything u said but an error comes up saying "failed to open Fpscontroller.lua"

 

And then amother saying " ')' expected near 'GraphicsWitdth' "

 

 

P.S I also saw the "VisualKnights Developer Diary - 1 - Mission Tab" video. It looks great!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...