How to move camera using keyboard and mouse

Home Forums Programming How to move camera using keyboard and mouse

This topic contains 11 replies, has 4 voices, and was last updated by Yuri Kovelenov Yuri Kovelenov 1 week, 1 day ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #20867

    Hello, everyone. Before going into topic I just want to say I am delighted after 10 years of dreaming to discover a tool like this which allows my photography website to become 3D… I am learning Blender now and I have imported some objects and created my own gallery with photographies as paintings on the wall.

    What I want is to be able to override the default W,A,S,D keys in order to have the user smoothly advance through the floor while at the same being unable to pass through objects. For example, I do not want them to be able to climb up the stairs at this momeent or through the sustaining walls or even the floor itself… How could I possibly do that?

    I searched through the forum and found ways to retrieve the camera and to set its position upon pressing a key. I even wrote a piece of code for the key ‘W’ and while the console shows it has been pressed the camera still jumps… and tweening animation is not smooth for me, it is too jumpy. Any resources would help besides the manual (and I suppose the book is not yet written).

    Thank you very much!

    #20905

    Hi, thanks you for your kind words.
    To move you camera in character mode, assign the First-person controls for your camera and then use some mesh below it to be a floor. See the city example in our Verge3D distribution (located in applications/city folder).

    Co-founder and CTO at Soft8Soft
    FB | Twitter | VK

    #20911

    Thank you for your reply! Yes, I have successfully done that. The only issue remains that it will still go through paintings, walls and other materials. I am trying to assign the “Collision material” to more than one object but it did not work somehow, how can I bypass the restriction of having just one collision material?

    #20915
    Avatar
    johngrigni
    Licensee

    You can make ‘breaks’ in the floor object near the walls. You could make the floor object separate from the visible floor for this purpose.

    #20922

    @johngrigni : Interesting suggestion. Could you please elaborate a little? From my understanding, I have created a spatial gap between the wall and the floor and added a floor behind the wall, but it would be inefficient to duplicate the floor just to act as a solid object behind the others. I apologize for the misuse of Blender or English if that is the case. I might even share the .blend file or something.

    #20923
    Avatar
    johngrigni
    Licensee

    Basically any gap in the floor object is impassable. So if you make cuts in the mesh of the floor object, they can’t walk past the interruption, but they can walk through a door. Or they can walk up a ramp as stairs.

    Attachments:
    You must be logged in to view attached files.
    #20955

    I finally get it. I will update this if I was able to do it or not. Very interesting, I would have never expected something like this. According to your drawing, everything should be separated if I want the user to be unable to reach. But the limitation is the empty space itself. The user will see the gray background and lots of gaps I must be forced to fill somehow in order for it not to look ugly… are we sure this is the only way?

    #20956
    Avatar
    johngrigni
    Licensee

    The actual floor object doesn’t have to be visible. It can be just below the visual floor object, which wouldn’t have any holes

    #20964

    Thank you. I have tried it. I found some interesting stuff. The scene I bought has an interior gallery. Camera does not go through the floor, it is perfect. It goes through walls, but stops after about 1 meter or so… Both the walls and the floor have the same “Floor” material applied with the same variables. I made sure the clip is set to a low value (0.1), I modified the gaze accordingly, made sure the object is also rough and pretty much tried many things I found about Blender on forums, but I got bad luck.

    When I add the “Floor” material to other objects for some reason it still goes through though… any other ideas?

    #20978
    Avatar
    johngrigni
    Licensee
    #21060

    This actually seems to do the trick! Just wanted to confirm. Thank you so much :good: !!

    #21066
    Yuri Kovelenov
    Yuri Kovelenov
    Developer

    @vergegraphy glad you found a solution!
    @johngrigni thanks for helping out!

    3D Verger, the CEO
    LinkedIn | FB | Twitter | VK | 新浪微博

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.