Forum rules - please read before posting.

Gravity issue

edited June 2016 in Technical Q&A
In Adventure point and click games you ussualy want the ability to skip a walk distance by for example double clicking, so the character is immediately teleported to it's destination.

This principle is already integrated in my game thankfully but I have a small issue:

if the character is teleported, sometimes it looks like he is bouncing a bit and this just looks silly. This is because gravity is still on. I thought about to freeze the Rigidbody constraints, the Y axis especially but this is very hard for me to achieve without editing the AC scripts. I don't want to do that. So my question is: how do I do this?

There is also a way that I could just use the Hotspot's Triggers interaction instantly, but I don't know how to do that via script. I could only find the enum DoubleClickingHotspot.TriggersInteractionInstantly. But I need "when the player doubleclicked on a hotspot " but can't find how to do that in the scripting manual from AC.
So I could for example Disable the Gravity from the Playerscript at this moment. 

Comments

  • I agree that an OnDoubleClickHotspot event would be useful.  However, disabling gravity might not be the answer here - it could be that you instead need to set the Rigidbody's velocity to (0,0,0).

    Either way, I'll look into adding that as an event handle.
  • Thank you Chris!
  • However, disabling gravity might not be the answer here - it could be that you instead need to set the Rigidbody's velocity to (0,0,0).

    Have the same bouncing NPC issue. I see Rigidbody Velocity under the Info section on the Rigidbody Compnent but it is greyed out. Where can I set it?

  • Through script:

    GetComponent <Rigidbody>().velocity = Vector3.zero;
    
  • So would I put that in a custom script and add that as a component to the bouncing NPC?

  • Yes - and then run it when you wish.

    When is the NPC "bouncing"?

  • edited May 2020

    When he his moving between nodes. It's not constant but he does bounce multiple times as he approaches the second Node. It is something to do with his rigidbody or collider reacting to the floor (I think). The floor is horizontal and a flat cube and the NPC collider is not clipping it before launching the game or during play.

    I set ignore gravity on the NPC and Override Gravity on the Nodes he moves smooth as butter. Same case if I Freeze Y Position. However, these are not good solutions because I will have different NPCs of different heights in my game and so having them all be at the Y positions of the same Nodes will mean some of their feet won't touch the floor. So Gravity is needed here.

  • A character's origin should be where their feet are. If your sprite-based character's origin is in the centre of their graphic, you should amend their sprite's Pivot Point to the Bottom.

    See the 2D Demo's Player prefab, Brain2D, for an example.

    Also know that you can replace a Rigidbody with a Character Controller, if desired.

  • edited May 2020

    I set the Pivot Point on the Sprite to Bottom but he still bounces.

    Using Character Controller instead of Rigid Body works well though. However, having Retro Style Movement ticked now seems to make the NPC jitter when turning at the Node.

    Is there a known conflict between Character Controller and Retro Style Movement and Nodes?

    Also, am I right in thinking I no longer need a Collider when using a Character Controller because its built in?

  • The pivot point and bouncing are separate issues, but the pivot should be at the bottom regardless.

    "jitter" how exactly? There's no need for a Collider and Character Controller together.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.