Movement of the mouse, causing sprite to move

DEFOLD EDITOR AND ENGINE BUGS

Report engine and editor bugs on GitHub. We will not accept engine and editor bug reports here.

Link to the reported GitHub issue in your forum post to get visibility and discuss with the community and dev team.

OTHER BUGS

For bugs discovered in extensions, on the website or with any of our services please provide the following information:

Describe the bug (REQUIRED)
When I move my mouse it causes the character to move to the left.

To Reproduce (REQUIRED)
Steps to reproduce the behaviour:

  1. Go to ‘santa.script’
  2. Click on ‘…’
  3. Scroll down to ‘line 39’
  4. See error

Expected behaviour (REQUIRED)
When I move my mouse my character shouldn’t move, only when I press the arrow keys. I should only be able to click on Resume and Quit when I press 0.

Defold version (REQUIRED):

  • Version 1.11.2

Platforms (REQUIRED):

  • Platforms: Windows
  • OS: Windows 10
  • Device: hp computer

Minimal repro case project (OPTIONAL):
Please attach a minimal project where the bug is reproduced. This will greatly help the person trying to investigate and fix the bug.

Logs (OPTIONAL):
Please provide relevant logs from engine, editor or build server. Learn where the logs are stored here.

Workaround (OPTIONAL):
If there is a workaround, please describe it here.

Screenshots (OPTIONAL):
If applicable, add screenshots to help explain your problem.

Additional context (OPTIONAL):
I think that it may have something to do with velocity.

I think this is a problem with the on_input function and not a bug. The way you check for actions can cause unexpected problems.
For example when you check for if action_id ~= hash(“jump”), you technically accept all inputs as long as they are not the jump input (which is space)

When you move your mouse, that is an input. Your code checks if it is the jump input, it is not. So, it enters the first if statement. Then checks if it is the right input, as it is not, it treats the mouse as left action and move your player to the left. Instead of using “~= hash(“jump)”, you should use

if action_id == hash(“right) or action_id == hash(“left”) then

The internal part can stay the same.

Make sure to apply this approach to all input logic as “not equal to” check is not the correct way here :slight_smile:

4 Likes