Constrain Linear Velocity Issues

KrakenCMTKrakenCMT Member Posts: 22
edited November -1 in Working with GS (Mac)
I have a game I'm working on where when the player lands on some spikes, he gets stuck for a second, then dies and falls. There's other instances where the player is supposed to get stuck as well. Right now, I'm using a boolean attribute to constrain the linear velocities to 0 when he hits the spikes or whatever is supposed to trap him.

The problem is that I've recently added gravity to the game because I've added some particles which I want gravity to effect. But now when the player gets stuck and the boolean attribute constrains the actor, the actor still moves down slowly due to the gravity acting on it. How can I get the actor to be immovable when I want him stuck somewhere? Anyone else run into this issue?

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    instead of constraing the linear velocity try this

    make 2 real attribute call them stayX and stayY

    when the actor collides with the spikes change stayX to self position x and change stayY

    then constrain self position x to stayX and constrain self position y to strayY
  • KrakenCMTKrakenCMT Member Posts: 22
    That did it! Thanks a bunch! I'm glad it was an easy fix. :)
Sign In or Register to comment.